Guest User

Untitled

a guest
Feb 12th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. protected void Button1_Click(object sender, EventArgs e)
  2. {
  3.  
  4. try
  5. {
  6. MailMessage mail = new MailMessage();
  7. mail.To.Add("color.shadow@yahoo.com");
  8.  
  9. mail.From = new MailAddress("abc@gmail.com");
  10. mail.Subject = "Reservation Status";
  11.  
  12. string Body = "Greeting from us." +
  13. " You may view your booking details at your profile now." +
  14. " Have a nice day." +
  15. "Thank you.";
  16. mail.Body = Body;
  17.  
  18. mail.IsBodyHtml = true;
  19.  
  20. SmtpClient smtp = new SmtpClient("localhost", 25);
  21. smtp.Host = "smtp.gmail.com";
  22. smtp.Credentials = new System.Net.NetworkCredential
  23. (abc@gmail.com", "abcdef");
  24.  
  25. smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
  26. smtp.EnableSsl = true;
  27.  
  28. smtp.Send(mail);
  29. Label1.Text = "Mail Send...";
  30. }
  31. catch (Exception ex)
  32. {
  33. Label1.Text = ex.Message;
  34. }
  35. }
Add Comment
Please, Sign In to add comment