private static int sendemail(string bomEmailId, int customerId, string userName)
{
int ismailsend = 0;
StringBuilder stringbuilder = new StringBuilder();
MailAddress to = new MailAddress(bomEmailId);
MailAddress from = new MailAddress("shoping@indiashoponline.com");
MailMessage mailMessage = new MailMessage(from, to);
System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential();
//SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
SmtpClient smtpClient = new SmtpClient("mail.indiashoponline.com");
stringbuilder.Append("
Dear, ").Append(userName).Append(" |
")
.Append("This is a online purchase confirmation mail from indiashoponline for the product and your shopping id is").Append(customerId).Append(". |
")
.Append("In the case of any issue you can you can contact indiashoponline with your shopping id.And thank you for purchasing with us. |
")
.Append("Best Regards... |
")
.Append("Thank you for using indiashoponline. |
")
.Append("phone:.................. |
)");
try
{
networkCredential.UserName = "sdfsdf@indiashoponline.com";//need to add valid user id
networkCredential.Password = "sdfsdf";// need to add valid password
//smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = false; // your domain
smtpClient.Credentials = networkCredential;
mailMessage.Subject = "Shopping @ IndiaShopOnline";
mailMessage.IsBodyHtml = true;
mailMessage.Body = stringbuilder.ToString();
smtpClient.Send(mailMessage);
ismailsend = 1;
}
catch (Exception ex)
{
ismailsend = 0;
string error= ex.Message;
}
finally
{
mailMessage = null;
networkCredential = null;
smtpClient = null;
}
return ismailsend;
}
No comments:
Post a Comment