G
Guest
I have a web page that sends emails to a mailing list of 700+ recipients. It
ran to about 435 and quit, and was unable to make a connection to send again.
I do not yet have verification that the 400+ emails actually arrived.
I *think* but do not know for sure that my smtp server is exchange. It is
hosted with an isp (webhost4life).
1) It was recently posted that smtpclient caches the connection. Not sure if
this is related. Thoughts?
2) Could I be overflowing the server in some way? Any ideas on how to avoid
this, even at a conceptual level for another approach to sending?
3) If I dispose of and re-create the message object, could that possibly help?
4) If I put in some form of delay to not blast the emails in to the server
so fast, could this help me get more messages through?
Kinda hard to test this and test the theories when I need to send 400+
emails for each test before the error strikes!
Code is as follows:
Dim netMsg As New System.Net.Mail.MailMessage
Try
With netMsg
.Body = "<p>Hi there</p>"
.IsBodyHtml = True
.Subject = "Test Email"
.Priority = Net.Mail.MailPriority.Normal
.From = New System.Net.Mail.MailAddress("(e-mail address removed)")
.ReplyTo = New System.Net.Mail.MailAddress("(e-mail address removed)")
.Sender = New System.Net.Mail.MailAddress("(e-mail address removed)")
End With
Dim mySMTP As New System.Net.Mail.SmtpClient("mail.mydomain.com")
mySMTP.Credentials = New
System.Net.NetworkCredential("(e-mail address removed)", "supersecretpassword")
'ENTER LOOP
'The code here would point to more stuff than is relevant. Just believe me
that this loop fetches email addresses one at a time.
For each address as string in AddressSource
netMsg.To.Clear()
netMsg.To.Add(New System.Net.Mail.MailAddress(address))
mySMTP.Send(netMsg)
Loop
The error message I get is:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.IO.IOException: Unable to read data from the transport connection:
net_io_connectionclosed. at
System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32
offset, Int32 read, Boolean readLine) at
System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller,
Boolean oneLine) at
System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at
System.Net.Mail.SmtpReplyReader.ReadLine() at
System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at
System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at
System.Net.Mail.SmtpClient.GetConnection() at
System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner
exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage
message) at HAI.MailMeister.ListAdmin.BroadcastEngine.BackgroundMail()
============================================
Feel free to call my questions stupid. It''s better than calling me an
inquisitive idiot with good questions.
ran to about 435 and quit, and was unable to make a connection to send again.
I do not yet have verification that the 400+ emails actually arrived.
I *think* but do not know for sure that my smtp server is exchange. It is
hosted with an isp (webhost4life).
1) It was recently posted that smtpclient caches the connection. Not sure if
this is related. Thoughts?
2) Could I be overflowing the server in some way? Any ideas on how to avoid
this, even at a conceptual level for another approach to sending?
3) If I dispose of and re-create the message object, could that possibly help?
4) If I put in some form of delay to not blast the emails in to the server
so fast, could this help me get more messages through?
Kinda hard to test this and test the theories when I need to send 400+
emails for each test before the error strikes!
Code is as follows:
Dim netMsg As New System.Net.Mail.MailMessage
Try
With netMsg
.Body = "<p>Hi there</p>"
.IsBodyHtml = True
.Subject = "Test Email"
.Priority = Net.Mail.MailPriority.Normal
.From = New System.Net.Mail.MailAddress("(e-mail address removed)")
.ReplyTo = New System.Net.Mail.MailAddress("(e-mail address removed)")
.Sender = New System.Net.Mail.MailAddress("(e-mail address removed)")
End With
Dim mySMTP As New System.Net.Mail.SmtpClient("mail.mydomain.com")
mySMTP.Credentials = New
System.Net.NetworkCredential("(e-mail address removed)", "supersecretpassword")
'ENTER LOOP
'The code here would point to more stuff than is relevant. Just believe me
that this loop fetches email addresses one at a time.
For each address as string in AddressSource
netMsg.To.Clear()
netMsg.To.Add(New System.Net.Mail.MailAddress(address))
mySMTP.Send(netMsg)
Loop
The error message I get is:
System.Net.Mail.SmtpException: Failure sending mail. --->
System.IO.IOException: Unable to read data from the transport connection:
net_io_connectionclosed. at
System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32
offset, Int32 read, Boolean readLine) at
System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller,
Boolean oneLine) at
System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) at
System.Net.Mail.SmtpReplyReader.ReadLine() at
System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at
System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at
System.Net.Mail.SmtpClient.GetConnection() at
System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner
exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage
message) at HAI.MailMeister.ListAdmin.BroadcastEngine.BackgroundMail()
============================================
Feel free to call my questions stupid. It''s better than calling me an
inquisitive idiot with good questions.