I have a VB.net Application running on the server which will be sending emails close to 200 everyday. Following is my coding:
Dim objNewMail = CreateObject("CDO.Message")
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objNewMail.Configuration.Fields.Update()
objNewMail.From = mailFrom
objNewMail.To = mailTO
objNewMail.CC = mailCC
objNewMail.bcc = mailBCC
objNewMail.Subject = mailSubject
objNewMail.HTMLBody = content
objNewMail.Send()
objNewMail = Nothing
The above codes runs inside a loop. The above code runs quite well without any issues. But once or twice a month, i get the following error message and application stops.
System.Runtime.InteropServices.COMException (0x80040213): The transport failed to connect to the server.
Can anybody help me fixing this issue or i m also open for any other better and advanced approach.
You might want to wrap the .Send() call in a Try...Catch and retry after a few seconds if it fails.
CDO appears to have been deprecated in favour of System.Net.Mail. There is a site with a comprehensive FAQ for it at www.systemnetmail.com/ , although I would be looking in the event logs for an occassional error like that.
Is there anything else coincident with the error, for example the server has just rebooted?
User contributions licensed under CC BY-SA 3.0