wwdnet
asked on
Email to Multiple Recipients is Dropping Recipient
I am using the following code to send an Access report to multiple recipients:
Dim rst As DAO.Recordset
Dim sEmails As String
Set rst = CurrentDb.OpenRecordset("S ELECT [EMAILADR] FROM [EMAILTEMP]")
Do Until rst.EOF = True
sEmails = rst("EMAILADR") & ";" & sEmails
sEmails = Left(sEmails, Len(sEmails) - 1)
rst.MoveNext
Loop
DoCmd.SendObject acSendReport, "rptDOCNEW", acFormatPDF, sEmails, , , "TEST EMAIL - DISCARD", "A new document is awaiting your approval. Please review as soon as possible.", False
************************** *****
Of the 3 listed entries, only 2 were emailed. I have tried this without the (= True) after rst.EOF and a couple of other ways, but the result is the same.
I am querying the email addresses into a temporary table prior to running the code, and all recipients are added to the temporary table.
Any help would be greatly appreciated. This database is going into production within a week and I need to get the code working to use in several other forms.
Dim rst As DAO.Recordset
Dim sEmails As String
Set rst = CurrentDb.OpenRecordset("S
Do Until rst.EOF = True
sEmails = rst("EMAILADR") & ";" & sEmails
sEmails = Left(sEmails, Len(sEmails) - 1)
rst.MoveNext
Loop
DoCmd.SendObject acSendReport, "rptDOCNEW", acFormatPDF, sEmails, , , "TEST EMAIL - DISCARD", "A new document is awaiting your approval. Please review as soon as possible.", False
**************************
Of the 3 listed entries, only 2 were emailed. I have tried this without the (= True) after rst.EOF and a couple of other ways, but the result is the same.
I am querying the email addresses into a temporary table prior to running the code, and all recipients are added to the temporary table.
Any help would be greatly appreciated. This database is going into production within a week and I need to get the code working to use in several other forms.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim rst As DAO.Recordset
Dim sEmails As String
DIM X AS INTEGER, Y AS INTEGER
Set rst = CurrentDb.OpenRecordset("S ELECT [EMAILADR] FROM [EMAILTEMP]")
RST.MOVELAST
X=RST.RECORDCOUNT
RST.MOVEFIRST
FOR Y=1 to X
sEmails = rst("EMAILADR") & ";" & sEmails
sEmails = Left(sEmails, Len(sEmails) - 1)
rst.MoveNext
NEXT Y
Dim sEmails As String
DIM X AS INTEGER, Y AS INTEGER
Set rst = CurrentDb.OpenRecordset("S
RST.MOVELAST
X=RST.RECORDCOUNT
RST.MOVEFIRST
FOR Y=1 to X
sEmails = rst("EMAILADR") & ";" & sEmails
sEmails = Left(sEmails, Len(sEmails) - 1)
rst.MoveNext
NEXT Y
ASKER
I am breathing a sigh of relief! Thank you, and also RemRem. It took a while to test this because there were some other issues in the module. I chose the first solution as the simplest option for a complex process in which some of the list members will be notified one day, and others added later requiring notification of the new members. There are a number of related forms that depend on the notification and related responses, and each will need what will basically be the same code with minor changes.
I got this to work for all the non-notified members after commenting out subsequent code that appeared to be running ahead of the loop. I can work out the rest of the code in the morning!
I got this to work for all the non-notified members after commenting out subsequent code that appeared to be running ahead of the loop. I can work out the rest of the code in the morning!
ASKER
Exl04: I did not intentionally leave you out of the thank you. I will try the other suggested codes and see if they will work for this project.
Open in new window