使用 ASP.NET 发送邮件

发布于 2024-10-20 02:53:26 字数 688 浏览 1 评论 0原文

我对 ASP.NET 比较陌生,如果这是一个新手问题,我很抱歉。我正在尝试使用 ASP.NET 发送电子邮件,但它不断抛出:

500 - 内部服务器错误。 您要查找的资源有问题,无法显示。

该错误在尝试实际发送邮件时发生。所以所有这些都工作正常:

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="[email protected]"
myMail.To="[email protected]"
myMail.TextBody="This is a message."

但是总是在这一行生成错误:

myMail.Send

那么什么可能导致这个问题呢?

I'm relatively new to ASP.NET so sorry if this is a newbie question. I am trying to send an email with ASP.NET but it keeps throwing a:

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

The error occurs as the point in which the mail is attempted to actually send. So all of this works fine:

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="[email protected]"
myMail.To="[email protected]"
myMail.TextBody="This is a message."

But the error is generated at this line always:

myMail.Send

So what could be causing this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

征棹 2024-10-27 02:53:26

对于 ASP.NET,您最好使用 System.Net 中的SmtpClient 类。

SmtpClient mailClient = new SmtpClient("mysmtpserver.somedomain.com",25);
MailMessage msg = new MailMessage();
msg.From = new MailAddress("[email protected]", "My Name");
msg.To.Add("[email protected]");
msg.Subject = "This is the message subject";
msg.Body = "This is a message.";
mailClient.Send(msg);

For ASP.NET you would be better off using the SmtpClient class in System.Net.

SmtpClient mailClient = new SmtpClient("mysmtpserver.somedomain.com",25);
MailMessage msg = new MailMessage();
msg.From = new MailAddress("[email protected]", "My Name");
msg.To.Add("[email protected]");
msg.Subject = "This is the message subject";
msg.Body = "This is a message.";
mailClient.Send(msg);
云淡月浅 2024-10-27 02:53:26

为了更好地了解导致错误的真正原因,您可能需要取消选中浏览器中的“用户友好错误消息”。以下是在 Internet Explorer 中的操作方法

  1. 打开 IE
  2. 单击“工具”菜单
  3. 单击“Internet 选项”
  4. 单击“高级”选项卡
  5. 取消选中“显示友好 HTTP 错误消息”
  6. 单击“确定”

查看是否有可能对您有帮助的其他信息。

To get a better idea of what is really causing the error, you might want to uncheck the "user friendly error messages" in your browser. Here's how in Internet Explorer

  1. Open IE
  2. Click the Tools Menu
  3. Click Internet Options
  4. Click the Advanced tab
  5. Uncheck Show Friendly HTTP Error Messages
  6. Click OK

See if you get any additional information there which might help you.

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