SPUtility 发送电子邮件时出错
我试图在 Web 部件中的按钮单击事件中发送电子邮件。但是,电子邮件发送失败,并且计算机的共享点日志和事件查看器中都会记录错误。 错误是:无法连接到 SMTP 主机
已配置中央管理中的传出电子邮件设置。警报也运行良好。
以下是我的代码:
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);
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在没有系统帐户的情况下运行代码(如果是)。
另请尝试禁用LoopbackCheck:
要设置DisableLoopbackCheck注册表项,请按照下列步骤操作:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
Try running your code without the System Account (if you are).
Try also disabling the LoopbackCheck:
To set the DisableLoopbackCheck registry key, follow these steps:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
我已经解决了。防病毒软件导致了这个问题。但我想知道SharePoint如何能够发送邮件呢?
I got that fixed. Anti virus was causing the problem. But i am wondering how is SharePoint able to send mail then?