Guest User

Untitled

a guest
Jul 12th, 2018
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. Using System.Net.Mail; //Include This NameSpace
  2.  
  3.  
  4.  
  5.  
  6. MailMessage MyMailMessage = new MailMessage();
  7.  
  8. MyMailMessage.From = new MailAddress("cadbuaryguy@gmail.com");
  9.  
  10. MyMailMessage.To.Add("learninggeeks@yahoo.com");
  11.  
  12. MyMailMessage.Subject = "Feedback Form";
  13.  
  14. MyMailMessage.IsBodyHtml = true;
  15.  
  16. MyMailMessage.Body = "<table><tr><td>" + txtName.Text + txtEmail.Text + txtComments.Text + "</table></tr></td>";
  17.  
  18. SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com");
  19.  
  20. SMTPServer.Port = 587;
  21.  
  22. SMTPServer.Credentials = new System.Net.NetworkCredential("cadbuaryguy@gmail.com", System.Configuration.ConfigurationSettings.AppSettings["pwd"].ToString());
  23.  
  24. SMTPServer.EnableSsl = true;
  25.  
  26. try
  27.  
  28. {
  29.  
  30. SMTPServer.Send(MyMailMessage);
  31.  
  32. Response.Redirect("Thankyou.aspx");
  33.  
  34. }
  35.  
  36. catch (Exception ex)
  37.  
  38. {
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. }
Add Comment
Please, Sign In to add comment