SPUtility 发送电子邮件时出错

发布于 2024-08-28 16:35:58 字数 824 浏览 7 评论 0原文

我试图在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

差↓一点笑了 2024-09-04 16:35:58

尝试在没有系统帐户的情况下运行代码(如果是)。

另请尝试禁用LoopbackCheck

要设置DisableLoopbackCheck注册表项,请按照下列步骤操作:

  • 单击“开始”,单击“运行”,键入 regedit,然后单击“确定”。
  • 在注册表编辑器中,找到并单击以下注册表项:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  • 右键单击​​“Lsa”,指向“新建”,然后单击“DWORD 值”。
  • 键入“DisableLoopbackCheck”,然后按 Enter。
  • 右键单击“DisableLoopbackCheck”,然后单击“修改”。
  • 在“值数据”框中,键入 1,然后单击“确定”。
  • 退出注册表编辑器,然后重新启动计算机。

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:

  • Click Start, click Run, type regedit, and then click OK.
  • In Registry Editor, locate and then click the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  • Right-click Lsa, point to New, and then click DWORD Value.
  • Type DisableLoopbackCheck, and then press ENTER.
  • Right-click DisableLoopbackCheck, and then click Modify.
  • In the Value data box, type 1, and then click OK.
  • Quit Registry Editor, and then restart your computer.
懒猫 2024-09-04 16:35:58

我已经解决了。防病毒软件导致了这个问题。但我想知道SharePoint如何能够发送邮件呢?

I got that fixed. Anti virus was causing the problem. But i am wondering how is SharePoint able to send mail then?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文