Friday, March 16, 2012

mass e mail go stuck.

I use this code to send e mail to all my web register users:

Sub Mailshot(ByVal adress As String, ByVal subject As String, ByVal body As String)
Dim msgmail As MailMessage = New MailMessage()

SmtpMail.SmtpServer = "smtp.012.net.il"

msgmail.From = "shoresh<shoresh@dotnet.itags.org.shoresh.org.il>"

Try
msgmail.To = adress
msgmail.Body = body
msgmail.Subject = subject
msgmail.BodyFormat = MailFormat.Html
SmtpMail.Send(msgmail)
Catch exc As Exception
'DO WHATEVER ERROR HANDLING
End Try

msgmail = Nothing
End Sub

I"m calling the sub again and again using for... next loop.

The problem is that the site got stuck while sending.

do you have an idea why?
doe's it has something to do with the time needed to run code? if yes, hoe do i long this time?

thanks.What do you mean the site got stuck? How many emails are you sending? If there are a lot, its conceivable that the operation could time out.. are you getting any errors? I see you ahve an empty catch block, you might want to have something setup to see if you are getting errors from your SMTP server..
Increase the timeout in your web.config

<httpRuntime
executionTimeout="900"
/>

0 comments:

Post a Comment