Error in SPUtility send email

Posted by Faiz on Stack Overflow See other posts from Stack Overflow or by Faiz
Published on 2010-04-07T11:26:30Z Indexed on 2010/04/07 11:33 UTC
Read the original article Hit count: 291

Filed under:
|
|

Hi,

I am trying to send an email in the button click event in the webpart.However, the email sending is failed and error is logged in both sharepoint logs and event viewer of the machine. The error is : Cannot connect to SMTP host

Outgoing email settings in central admin is already configured. Alerts are also working fine.

Below is my code:

 StringDictionary headers = new StringDictionary();
 headers.Add("to", "[email protected]");
 headers.Add("from", "[email protected]");
 headers.Add("subject", "How to use SendEMail from SPUtility");
 headers.Add("content-type", "text/html"); 
 string bodyText = "This is the body of my email, in html format.";
 SPUtility.SendEmail(SPContext.Current.Web, headers, bodyText);

Thanks in advance

© Stack Overflow or respective owner

Related posts about sharepoint

Related posts about send