Sending multiple email code not working (1 Viewer)

wnicole

New member
Local time
Yesterday, 22:07
Joined
Sep 28, 2013
Messages
9
I have this code below its giving me the RUntime 2295 error. Unknown message recipients. I have check all email addresses and they are fine. Everything else works except when it gets to Outlook and do not send email. Can you take a look let me know what you think? I did a Debug Print but didnt understand how to do it.

Private Sub Command9_Click()
Dim rst As DAO.Recordset
Dim strEmailAddress


Set rst = CurrentDb.OpenRecordset("T_Inspectors")

Do Until rst.EOF
strEmailAddress = strEmailAddress & rst("Email") & ","
rst.MoveNext
Loop

strEmailAddress = Left(strEmailAddress, Len(strEmailAddress) - 1)

DoCmd.SendObject acSendReport, "R_WeeklyDispatch_Today", acFormatPDF, strEmailAddress, _
, , "Job Alert", "Please see current jobs", True

rst.Close
Set rst = Nothing
End Sub
 

pr2-eugin

Super Moderator
Local time
Today, 06:07
Joined
Nov 30, 2011
Messages
8,494
As I have already mentioned in the other thread.. Try debugging, copy and paste the generated String here..

Unless you wish to do some work, we will not be able to help you.. :rolleyes:
 

pr2-eugin

Super Moderator
Local time
Today, 06:07
Joined
Nov 30, 2011
Messages
8,494
I would like to see..
then the email addresses.
This is what exactly I was saying, the problem might be with the missing emails..
1. It appears the employees without email addresses may be trigerring it. Is there a Is Null statement you can send me. I dont know how to create one in VBA.
Add a line to differentiate the Null/ZLS fields.. Something along the lines of..
Code:
    Do Until rst.EOF
        [COLOR=Red][B]If Len(rst("Email") &  vbNullString) <> 0 Then[/B][/COLOR] strEmailAddress = strEmailAddress & rst("Email") & ","
        rst.MoveNext
    Loop
2. I notice the email addresses was everybody in the table but not the specific ones based on the query. Was that normal? Is it telling me the code is wrong and will send to everybody?
Check the Query (T_Inspectors) once again, see if it is actually filtering the table properly..
 

Bar_NZ

Registered User.
Local time
Today, 17:07
Joined
Aug 14, 2012
Messages
48
Hi, sorry to re-open this forum, but I used this code and am getting a Complie error: Variable not defined and the debugger takes me to the strSubject line.

Private Sub Command4_Click()
Dim rst As DAO.Recordset
Dim strEmailAddress
Set rst = CurrentDb.OpenRecordset("Just_Email")
Do Until rst.EOF
strEmailAddress = strEmailAddress & rst("Email") & ";"
rst.MoveNext
Loop
strEmailAddress = Left(strEmailAddress, Len(strEmailAddress) - 1)
DoCmd.SendObject , , acFormatRTF, strEmailAddress, _
, , strSubject, strEMailMsg, False, False
rst.Close
Set rst = Nothing
End Sub

What I am trying to do, is take all the addresses in my Just_Email table and BCC them all in one e-mail, and I don't want to send an attachment...

Could someone help me please. :banghead:
 

Users who are viewing this thread

Top Bottom