我正在尝试在 webpart 中的按钮单击事件中发送电子邮件。但是,电子邮件发送失败,并且在机器的共享点日志和事件查看器中都记录了错误。错误是:无法连接到 SMTP 主机
中央管理中的外发电子邮件设置已配置。警报也工作正常。
下面是我的代码:
StringDictionary headers = new StringDictionary();
headers.Add("to", "someone@abc.com");
headers.Add("from", "MySharePointEmail@myfatblog.co.uk");
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);
提前致谢