Send mail using webservice

  • Thread starter indianictesting indianic
  • Start date

I

indianictesting indianic

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
 
Ad

Advertisements

M

Mike 'Spike' Lovell

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
 
I

indianictesting indianic

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
 
Ad

Advertisements

P

Patrice

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" <[email protected]> a écrit dans le message de
groupe de discussion :
(e-mail address removed)...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top