Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. using System.Net;
  2. using System.Net.Mail;
  3.  
  4. namespace Email
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Program obj = new Program();
  11. obj.SendEmail("Just a Mock Message");
  12. }
  13. public void SendEmail(string emailBody)
  14. {
  15. MailMessage mail = new MailMessage("FromEmail.com","ToEmail.com");
  16. mail.Subject = "Testing my Application";
  17. mail.Body = emailBody;
  18. SmtpClient smtp = new SmtpClient("smtp.gmail.com",587);
  19. smtp.Credentials = new NetworkCredential()
  20. {
  21. UserName = "EmailExample.com",
  22. Password = "example123"
  23. };
  24.  
  25. smtp.EnableSsl = true;
  26. smtp.Send(mail);
  27. }
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement