I have one application that will create a task form for each level based on the approval of the previous level. When creating each task, I must send an email to users who are all involved in the task. For this, I use the SPUtility.SendEmail () method. But unfortunately, it hasn’t worked yet. The debugger successfully passed through the SendEmail method without any exceptions. but the value will always be false. The SMTP server runs for an application other than SP applications. My code is shown below.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite spSite = new SPSite(SiteURL))
{
using (SPWeb spWeb = spSite.OpenWeb())
{
headers = new StringDictionary();
headers.Add("to", To);
headers.Add("from", From);
headers.Add("cc", CC);
headers.Add("bcc", BCC);
if (Priority.Equals("High"))
{
headers.Add("X-Priority", "1 (Highest)");
headers.Add("X-MSMail-Priority", "High");
headers.Add("Importance", "High");
}
headers.Add("subject", Subject);
headers.Add("content-type", "text/html");
Status = SPUtility.SendEmail(spWeb, true, true, To, Subject, Body);
}
}
});
Please help me solve this problem. All suggestions will be appreciated. Thanks in advance.
source
share