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