Problem sending mass e mail.

yaniv

Centurion
Joined
Apr 15, 2002
Messages
167
Location
israel
I’m trying for weeks to send e mail to all the registered users on my web. I use this procedure:
Code:
    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@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 call the procedure using for…next loop:
Code:
            For i = fromnumber.Text To tonumber.Text
                email = Trim(myDS.Tables(0).Rows(i).Item(0))

                b = "<body dir=rtl><div align=center><table width=600><tr><td><BR><div align=center><a href='http://www.shoresh.org.il'><img src='http://www.shoresh.org.il/Images/menu2/logo.jpg' width=428 height=38 border=0></a></div><BR><BR><BR>"
                b = b & "<font face='tahoma' size=2>" & Trim(body.Text) & "<BR>"

                Mailshot(email, Trim(subject.Text), b)
            Next

when myDS is a dataset that contain my e mail list (something like 600).

The problem is that the program get stuck again and again. I tried everything I know, including running the loop for no more then 20 rows each time, in the third circle it got stuck.

What do I do wrong? Or other vise, do anybody knows a better way to send mail to the site users (not using the outlook express list, because I don't want my list to go to any user.)

Please help!
 
i'm not sure but there is a chance that you need to add some delay so that the smtp won't get fluded, it maybe has some kind of protection, if you add a delay of about 1-2 seconds maybe.
 
Make sure that you have proper error handling for the sending of the email. If the address is invalid, you'll want to skip it (and log it), and then continue. I'd focus on sending more than 3 emails to yourself (or another account you have access too) to double check that its not the smtp server.

P.S. We'd better not start getting spam from "shoresh<shoresh@shoresh.org.il>"
;)
 
Why not use the BCC on the mail object and semicolon each address in the list and send out only one email

Andy

btw- keep in mind if there is nothing in the to of the email some programs see the message as spam
 
I believe in this case if you don't specify a valid To address, you'll get a Generic (and unhelpful) CDO Message error.
 
Back
Top