Gowtham

Gowtham

  • NA
  • 516
  • 41.1k

Send email using email utitlity

Aug 2 2017 6:59 AM
I was working on sent email using server object model.
 
The code runs perfectly but I am missing something to configure.Also I configured smtp server in local host but I can't relate anything.
 
 On out going email settings:
 Outbound SMTP server:WIN-LP2NAII0NV
 From address:[email protected]
 To address:[email protected] 
 
 
codes were tried
 using (SPSite oSPSite = new SPSite("http://win-l9p2naii0nv:10001/")) //Site collection URL
{
using (SPWeb oSPWeb = oSPSite.OpenWeb()) //Subsite URL
{
StringDictionary headers = new StringDictionary();
headers.Add("to", "[email protected]");
headers.Add("subject", "Welcome to the SharePoint");
headers.Add("fAppendHtmlTag","True"); //To enable HTML format
System.Text.StringBuilder strMessage = new System.Text.StringBuilder();
strMessage.Append("Message from CEO:");
strMessage.Append("<span style='color:red;'> Make sure you have completed the survey! </span>");
SPUtility.SendEmail(oSPWeb, headers, strMessage.ToString());
}
}
 

Answers (5)