Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. try
  2. {
  3. Configuration configurationFile = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/web.config");
  4. System.Net.Configuration.MailSettingsSectionGroup mailSettings = configurationFile.GetSectionGroup("system.net/mailSettings") as System.Net.Configuration.MailSettingsSectionGroup;
  5.  
  6.  
  7. string from = string.Empty;
  8. if (mailSettings != null)
  9. {
  10. from = mailSettings.Smtp.From;
  11. }
  12. string myString="<html><head>test email tracking </head><body><p>this is test mail for email tracking</p></body></html>";
  13.  
  14. string toAddress = "mohanj@icore.net.in";
  15.  
  16. myString = myString.Replace("<body>", "<body><IMG height=1 src='http://icoremail.icore.net.in/testresponse.aspx?emailsent=" + toAddress + "' width=1></IMG>");
  17.  
  18.  
  19.  
  20. using (MailMessage message = new MailMessage(
  21.  
  22. // from, "mohanj.icore@gmail.com",
  23.  
  24. from, "mohanj@icore.net.in",
  25. "A report for you!", myString))
  26. {
  27. message.IsBodyHtml = true;
  28.  
  29. SmtpClient smtp = new SmtpClient();
  30.  
  31. smtp.Send(message);
  32. lblMessage.Text = " Mail Sent successfully! ";
  33.  
  34. }
  35. }
  36. catch (Exception ex)
  37. {
  38. Response.Write(ex.Message);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement