SmtpClient.send error

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.
 
S

sloan

3) If I dispose of and re-create the message object, could that possibly
help?

Why don't you try it?


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?


Why don't you try it?


Kinda hard to test this and test the theories when I need to send 400+
emails for each test before the error strikes!


You can setup a single email address, and send it the same email 700 times.
Then you'll get confirmation as well.
Or setup 2 emails, and alternate between them. I do this all the time.


Off topic slightly:
You can find my "cleaner" email setup with smtp here
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry


I usually just recreate the object, by calling the procedure (see my code)
over and over for large number of emails.
However, my large usually is about 50 at the most. Your large is larger.


.........






Pavlovs Mouse said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top