Main Page | Report this Page
.NET DotNet Forum Index  »  ASP.NET - Webservices Forum  »  Send mail using webservice...
Page 1 of 1    

Send mail using webservice...

Author Message
indianictesting indianic...
Posted: Tue Oct 20, 2009 11:44 pm
Guest
When I am trying to send mail while developing webservice, it
succeeds.but when I publish and upload webservice ,It gives excepttion
that "Failure sending mail"..
Thank you in advance
 
Mike 'Spike' Lovell...
Posted: Wed Oct 21, 2009 10:14 am
Guest
Quote:
When I am trying to send mail while developing webservice, it
succeeds.but when I publish and upload webservice ,It gives excepttion
that "Failure sending mail"..
Thank you in advance

You'd have to post the code, but perhaps the place you're putting it does
not have a working SMTP server, or it cannot reach the SMTP server you're
using from the location it's in.

~ Mike
 
Patrice...
Posted: Wed Oct 21, 2009 10:46 am
Guest
Hi,

Quote:
It gives excepttion
that "Failure sending mail"..

Try :
http://www.systemnetmail.com/faq/5.aspx to see how to get additional
details. As it works in your dev environment this is more likely a
configuration issue...



--
Patrice
 
indianictesting indianic...
Posted: Wed Oct 21, 2009 7:11 pm
Guest
This code works fine when developing and testing application, but
doesn't work after deploying..

source code:

[WebMethod]
public Boolean SendMail(string Username, string Password, string
To, string Subject, string Body)
{

SendMailFunction(MailFrom, ToMailId, MailSubject, Mailbody,
IsBodyHtml, CredentialName, CredentialPassWord);


return true;
}

private void SendMailFunction(string MailFrom, string ToMailId, string
MailSubject, string Mailbody, bool IsBodyHtml, string CredentialName,
string CredentialPassWord)
{
System.Net.Mail.MailMessage ObjMailMessage = new
System.Net.Mail.MailMessage();
SmtpClient Client = new SmtpClient();

MailAddress From = new MailAddress(CredentialName);
Client.Credentials = new System.Net.NetworkCredential
(CredentialName, CredentialPassWord);
ObjMailMessage.To.Add(ToMailId);
ObjMailMessage.From = From;
ObjMailMessage.Subject = MailSubject;

ObjMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
ObjMailMessage.BodyEncoding = System.Text.Encoding.UTF8;

ObjMailMessage.Body = Mailbody;
ObjMailMessage.IsBodyHtml = IsBodyHtml;
Client.Host = "smtp server";

Client.EnableSsl = false;

// Client.Port = 80;

try
{
Client.Send(ObjMailMessage);
}
catch (System.Net.Mail.SmtpException ex)
{
throw new Exception(ex.Message);
}
}

Thanks in advance
 
Patrice...
Posted: Thu Oct 22, 2009 11:20 am
Guest
It should't even compile (inside SendMail MailFrom etc... is not know).

Have you tried the link I gave earlier to find out more details about the
exception ? Also if you thrown a new exception you are actually loosing some
information. Don't use try/catch to keep the real exception intact. It
should give more info.

If not I would try to test the connectivity between the server and your smtp
server (which is likely not named smtp server I guess). See for example :
http://www.webpan.com/Customers/Email/SMTP_Authentication_Telnet_Test.htm

--
Patrice

"indianictesting indianic" <indianic09 at (no spam) gmail.com> a écrit dans le message de
groupe de discussion :
2492a8a7-d616-4c96-b84b-390a02f49101 at (no spam) 12g2000pri.googlegroups.com...
Quote:

This code works fine when developing and testing application, but
doesn't work after deploying..

source code:

[WebMethod]
public Boolean SendMail(string Username, string Password, string
To, string Subject, string Body)
{

SendMailFunction(MailFrom, ToMailId, MailSubject, Mailbody,
IsBodyHtml, CredentialName, CredentialPassWord);


return true;
}

private void SendMailFunction(string MailFrom, string ToMailId, string
MailSubject, string Mailbody, bool IsBodyHtml, string CredentialName,
string CredentialPassWord)
{
System.Net.Mail.MailMessage ObjMailMessage = new
System.Net.Mail.MailMessage();
SmtpClient Client = new SmtpClient();

MailAddress From = new MailAddress(CredentialName);
Client.Credentials = new System.Net.NetworkCredential
(CredentialName, CredentialPassWord);
ObjMailMessage.To.Add(ToMailId);
ObjMailMessage.From = From;
ObjMailMessage.Subject = MailSubject;

ObjMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
ObjMailMessage.BodyEncoding = System.Text.Encoding.UTF8;

ObjMailMessage.Body = Mailbody;
ObjMailMessage.IsBodyHtml = IsBodyHtml;
Client.Host = "smtp server";

Client.EnableSsl = false;

// Client.Port = 80;

try
{
Client.Send(ObjMailMessage);
}
catch (System.Net.Mail.SmtpException ex)
{
throw new Exception(ex.Message);
}
}

Thanks in advance
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Fri Dec 04, 2009 6:04 pm