Guest User

Untitled

a guest
Feb 12th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. private void SendMail(MailMessage msg)
  2. {
  3. try
  4. {
  5. var smtp = new SmtpClient();
  6. smtp.Send(msg);
  7. }
  8. catch (SmtpFailedRecipientException exFailed)
  9. {
  10. lblExSendMail.Text = exFailed.Message;
  11. }
  12. }
  13.  
  14. <system.net>
  15. <mailSettings>
  16. <smtp deliveryMethod="Network" from="xyz@xyz.com">
  17. <network host="smtpout.secureserver.net" port="80" userName="xyz@xyz.com" password="xyz-password" />
  18. </smtp>
  19. </mailSettings>
  20.  
  21. SmtpClient MySMTPClient;
  22. MailMessage myEmail;
  23. MySMTPClient = new SmtpClient("smtp.secureserver.net", 25);
  24. MySMTPClient.Credentials = new NetworkCredential("<MailID>", "<Password>");
  25. myEmail = new MailMessage(new MailAddress("<sender>"), new MailAddress("<receiver>"));
  26. myEmail.Body = "Email from Windows Azure Application";
  27. myEmail.Subject = "Email from Windows Azure";
  28. try
  29. {
  30. MySMTPClient.Send(myEmail);
  31. }
  32. catch (Exception ex)
  33. {
  34. // Display Exception Details
  35. }
Add Comment
Please, Sign In to add comment