开发者

Sending Mail with ASP.NET

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:

开发者_StackOverflow中文版
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."

But the error is generated at this line always:

myMail.Send

So what could be causing this problem?


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("mymail@mydomain.com", "My Name");
msg.To.Add("someone@somedomain.com");
msg.Subject = "This is the message subject";
msg.Body = "This is a message.";
mailClient.Send(msg);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜