Guest User

Untitled

a guest
Jan 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. SPSecurity.RunWithElevatedPrivileges(delegate()
  2. {
  3. using (SPSite spSite = new SPSite(SiteURL))
  4. {
  5. using (SPWeb spWeb = spSite.OpenWeb())
  6. {
  7. headers = new StringDictionary();
  8. headers.Add("to", To);
  9. headers.Add("from", From);
  10. headers.Add("cc", CC);
  11. headers.Add("bcc", BCC);
  12. if (Priority.Equals("High"))
  13. {
  14. headers.Add("X-Priority", "1 (Highest)");
  15. headers.Add("X-MSMail-Priority", "High");
  16. headers.Add("Importance", "High");
  17. }
  18. headers.Add("subject", Subject);
  19. headers.Add("content-type", "text/html");
  20. Status= SPUtility.SendEmail(spWeb, headers, Body);
  21. }
  22. }
  23. });
  24.  
  25. MailMessage message = new MailMessage(<mailFrom>, <recipientMail>);
  26. message.Subject = "<Subject>";
  27. message.Body = "<BODY>";
  28. SmtpClient smtp = new SmtpClient(<mailServer>, <mailPort>);
  29. smtp.Send(message);
Add Comment
Please, Sign In to add comment