Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2007

Tip: Looking for answers? Try searching our database.

SmtpClient.send error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pavlovs Mouse - 26 Sep 2007 18:56 GMT
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("admin@mydomain.com")
   .ReplyTo = New System.Net.Mail.MailAddress("admin@mydomain.com")
   .Sender = New System.Net.Mail.MailAddress("admin@mydomain.com")
 End With

 Dim mySMTP As New System.Net.Mail.SmtpClient("mail.mydomain.com")
 mySMTP.Credentials = New
System.Net.NetworkCredential("admin@mydomain.com", "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.
sloan - 27 Sep 2007 15:29 GMT
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.

........

>I have a web page that sends emails to a mailing list of 700+ recipients.
>It
[quoted text clipped - 66 lines]
> Feel free to call my questions stupid. It''s better than calling me an
> inquisitive idiot with good questions.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.