Sending multiple records in an email

jimday1982

Registered User.
Local time
Yesterday, 20:45
Joined
May 13, 2004
Messages
81
The code below is sending an e-mail to each e-mail address in my recordset, but it's sending one PER RECORD instead of PER E-MAIL ADDRESS...I can't find anything wrong - can you?

Code:
If Not rst1.EOF Then
    Do While Not rst1.EOF
        emailto = rst1("[email]")
        strbody1 = strbody1 & rst1("[ponumber]") & "," & rst1("[odr_date]") & "," & rst1("[supplierid]") & "," & rst1("[name]") & "," & rst1("[fax]") & "," & rst1("[contact]") & vbCrLf
        If emailto = strPrevEmail Then
            If Len(emailto) <> 0 And Left(emailto, 1) <> " " Then
                DoCmd.SendObject acSendNoObject, , , emailto, , , "Open POs from Dynadirect", "Open PO(s)" & vbCrLf & vbCrLf & strbody1, True
            Else
            End If
        Else
            strbody1 = ""
        End If
        strPrevEmail = rst1("Email")
        rst1.MoveNext
    Loop
End If

Thanks for your help.
 
Well how about this, is this even possible or am I just wasting my time?
 
I was able to do what you are looking for by using the following for generating an email To: string.

just move your e-mail routine after the following code and use the EAddrB as your "To:" variable.




Dim EAddrA As Variant
Dim EAddrB As Variant

Set EAddr = CurrentDb().OpenRecordset("qryEmail-Addresses")
Do Until EAddr.EOF
EAddrA = EAddr!EmailAddr
EAddrB = EAddrB & ";" & EAddrA
EAddr.MoveNext
Loop
EAddr.Close

If EAddrB = "" Then
Exit Sub
End If
 

Users who are viewing this thread

Back
Top Bottom