Friday, November 2, 2012

send email using my domain


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("")
         .Append("")
         .Append("")
         .Append("")
         .Append("")
         .Append("
Dear, ").Append(userName).Append("
This is a online purchase confirmation mail from indiashoponline for the product and your shopping id is").Append(customerId).Append(".
In the case of any issue you can you can contact indiashoponline with your shopping id.And thank you for purchasing with us.
Best Regards...
Thank you for using indiashoponline.
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