Hi,
I have this newsletter code, that takes emails from the recordset Tonews and sends a specific message + attach

dim cdoConfig
Set cdoConfig = CreateObject("CDO.Configuration") 
With cdoConfig.Fields  
        .Item(cdosmtpserverport) = 26
        .Item(cdoSendUsingMethod) = 2
        .Item(cdoSMTPServer) = smtpserver
        .Item(cdoSMTPAuthenticate) = 1  
        .Item(cdoSendUsername) = musername
        .Item(cdoSendPassword) = mpassword
        .Update  
    End With 
dim cdoMessage			

do while not Tonews.eof
    Set cdoMessage = CreateObject("CDO.Message")  
 
    With cdoMessage 
        Set .Configuration = cdoConfig 
        .From =  "raport@iisconsult.ro"
		.To = Tonews("email")
		.Subject = Session("title")		
        .HTMLBody = msg
         if  Session("attach") <> "" then 
  		.AddAttachment  "D:\Inetpub\wwwroot\iis2\upload" &  Session("attach") 
 end if
   
.Send 
     End With  
   Set cdoMessage = Nothing  
    Tonews.MoveNext 
loop

    Set cdoConfig = Nothing

Everything works fine, except that the email is transmitted twice to each receipient.

So I would like to help modify my code so that:
1. send message only once
2. split the recordset considering the following mail server restrictions:
- A mail box can't send more that 50 emails within 10 minutes.
- A mail box can' send an email to more that 30 recipients in each sending process.
- if are more than 1000 messages sent to swith to another account.

Thank you.

First check that that your mail server doesn't send everyone 2 emails anyway. I have a few clients that when they send an email, their server or mail program sends 2 of the same mail... every time.

So make sure that is not happening first.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.