Guest User

Untitled

a guest
Sep 2nd, 2018
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. I want to make a web application to sending mail [closed]
  2. using System.Net.Mail;
  3. using System.Net;
  4.  
  5. SmtpClient mailClient = new SmtpClient("smtp.gmail.com", "587");
  6. mailClient.EnableSsl = true;
  7. mailClient.Credentials = new NetworkCredential("gmail_username", "gmail_password");
  8. mailClient.Send("from@gmail.com",
  9. "to@gmail.com",
  10. "subject goes here",
  11. "email body goes here");
  12.  
  13. MailMessage message = new MailMessage();
  14. message.From = new MailAddress("sender@foo.bar.com");
  15. message.To.Add(new MailAddress("recipient1@foo.bar.com"));
  16. message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
  17.  
  18. message.Subject = "This is my subject";
  19. message.Body = "This is the content";
  20.  
  21. SmtpClient client = new SmtpClient();
  22. client.Send(message);
  23.  
  24. <system.net>
  25. <mailSettings>
  26. <smtp from="test@foo.com">
  27. <network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
  28. </smtp>
  29. </mailSettings>
  30. </system.net>
Add Comment
Please, Sign In to add comment