Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 SMTPClient Mail Failure

Author  Topic 

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2009-02-02 : 02:45:06
May i know what is wrong with this error and anyone knows how to resolve this -


if (isDebug == "true")
{

sApprover = ConfigurationManager.AppSettings.Get("debugEmail").ToString();
leaveitem.Approval1 = sApprover;
leaveitem.Approval2 = sApprover;

MailNotify mail5 = new MailNotify();
mail5.MailAddress = new System.Net.Mail.MailAddress(leaveitem.EmployeeID.ToString(), "Leave Application");
mail5.MailMessage.From = mail5.MailAddress;
mail5.MailMessage.To.Add(leaveitem.EmployeeID.ToString());

mail5.MailMessage.Subject = "Leave Application by " + htNames[leaveitem.EmployeeID.ToString()].ToString() + ": " + leaveitem.FromDate.ToString("dd-MMM") + " " + leaveitem.FromDateSession.ToString() + " to " + leaveitem.ToDate.ToString("dd-MMM") + " " + leaveitem.ToDateSession.ToString();
mail5.MailMessage.IsBodyHtml = true;
mail5.MailMessage.Body = "<table><tr><td colspan=\"2\"><font face=\"Arial\">" + "<strong>" +
htNames[leaveitem.EmployeeID.ToString()].ToString()
+ "</strong>" + " has applied for :</font></td></tr>" +
"<tr><td colspan=\"2\"> </td></tr>" +
"<tr><td width=\"120\"><font face=\"Arial\">Leave Type:</font></td><td><font face=\"Arial\"><strong>" + htLeaveType[leaveitem.LeaveType.ToString()].ToString()
+ "</strong></font></td></tr>"
+ "<tr><td width=\"120\"><font face=\"Arial\">No. of Days:</font></td><td><font face=\"Arial\"><strong>" + leaveitem.NoDays.ToString()
+ "</strong></font></td></tr>"
+ "<tr><td><font face=\"Arial\">From: </font></td><td><font face=\"Arial\"><strong>" +
leaveitem.FromDate.ToString("dd-MMM-yyyy") + " " +
leaveitem.FromDateSession.ToString() + "</strong></font></td></tr><tr><td><font face=\"Arial\">To: </font></td><td><font face=\"Arial\"><strong>" +
leaveitem.ToDate.ToString("dd-MMM-yyyy") + " " +
leaveitem.ToDateSession.ToString() + "</strong></font></td></tr>"
+ remarkscon
+ "<tr><td><font face=\"Arial\">Approval:</font></td><td><font face=\"Arial\"><strong>"
+ htNames[leaveitem.Approval1.ToString()].ToString()
+ "</strong></font></td></tr>"
+ "<tr><td colspan=\"2\"> </td></tr>"
+ "<tr><td colspan=\"2\"><font face=\"Arial\">Preliminary approval is bypassed as manager is away.</font></td></tr>"
+ "<tr><td colspan=\"2\"><font face=\"Arial\">This Application has been sent to " +
htNames[leaveitem.Approval1.ToString()].ToString() +
" for approval.</font></td></tr></table>";
mail5.MailSmtpClient.Send(mail5.MailMessage);



Error: {"Unable to read data from the transport connection: net_io_connectionclosed."} Send Failure.

The SMTPClient is not able to send email during debugging but was fine during when browse in a Browser.

   

- Advertisement -