Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Net;
  6. using System.Net.Mail;
  7. using System.Web;
  8.  
  9. namespace MSPTunisia.Models
  10. {
  11. public static class Mailer
  12. {
  13. public static int SendEmail(string to, string subject, string body)
  14. {
  15.  
  16. SmtpClient client = new SmtpClient()
  17. {
  18. Host = "smtp-mail.outlook.com", // if Gmail use : "smtp.gmail.com"
  19. Port = 587,
  20. EnableSsl = true
  21. };
  22.  
  23. client.Credentials = new NetworkCredential(
  24. "SENDER_EMAIL",
  25. "SENDER_EMAIL_PASSWORD");
  26.  
  27. MailMessage mm = new MailMessage();
  28. mm.From = new MailAddress("SENDER_EMAIL");
  29. mm.To.Add(to);
  30. mm.Subject = subject;
  31. mm.Body = body;
  32.  
  33. client.Send(mm);
  34. return 1;
  35. }
  36.  
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement