vdhieu
14-07-2005, 21:51
mình có làm thử một đoạn code gởi mail sao nó chạy lại báo lỗi sau:
The transport failed to connect to the server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.
Source Error:
Line 269: msg.BodyFormat = MailFormat.Html;
Line 270: SmtpMail.SmtpServer = "MyMailServer";
Line 271: SmtpMail.Send(msg);
Line 272: }
code của mình như sau:
MailMessage msg = new MailMessage();
StringWriter strWriter = new StringWriter();
HtmlTextWriter htmltxWriter = new HtmlTextWriter(strWriter);
htmltxWriter.RenderBeginTag("head");
htmltxWriter.RenderBeginTag("title");
htmltxWriter.Write("Thank you");
htmltxWriter.RenderBeginTag("body");
htmltxWriter.WriteLine("Mail Test");
htmltxWriter.WriteLine("Test mail");
htmltxWriter.RenderEndTag();
msg.From = "conrua@yahoo.com";
msg.To = emailBan.Trim();
msg.Subject = "Thank you";
msg.Body = strWriter.ToString();
msg.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = "MyMailServer";
SmtpMail.Send(msg);
Các bạn có cách nào sửa không?
The transport failed to connect to the server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.
Source Error:
Line 269: msg.BodyFormat = MailFormat.Html;
Line 270: SmtpMail.SmtpServer = "MyMailServer";
Line 271: SmtpMail.Send(msg);
Line 272: }
code của mình như sau:
MailMessage msg = new MailMessage();
StringWriter strWriter = new StringWriter();
HtmlTextWriter htmltxWriter = new HtmlTextWriter(strWriter);
htmltxWriter.RenderBeginTag("head");
htmltxWriter.RenderBeginTag("title");
htmltxWriter.Write("Thank you");
htmltxWriter.RenderBeginTag("body");
htmltxWriter.WriteLine("Mail Test");
htmltxWriter.WriteLine("Test mail");
htmltxWriter.RenderEndTag();
msg.From = "conrua@yahoo.com";
msg.To = emailBan.Trim();
msg.Subject = "Thank you";
msg.Body = strWriter.ToString();
msg.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = "MyMailServer";
SmtpMail.Send(msg);
Các bạn có cách nào sửa không?