Results 1 to 3 of 3
  1. #1
    jhrBanker is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    68

    Sending eMail (via DoCmd.SendObject) to multiple recipents

    I'm currently using the following code to automatically send e:Mail messages from Access (mdb db using Access2007). I want to add an additional static bcc to the message (ie; bcc2Name@yahoo.com). I've tried adding the name separated with a ";", but I'm getting a compile error (expected end of statement). Any suggestions?

    This is how I modified the code:
    DoCmd.SendObject , , _


    acFormatRTF, _
    strAssEmail, _
    strMgrEmail, _
    strBccEmail;"bcc2Name@Yahoo.com", _
    strSubj, _
    strMess, False, False

    Here's the existing code:

    Private Sub cmdSendRem1_Click()
    Dim dbs As Database
    Dim rs1 As Recordset
    ' Dim rs2 As Recordset
    Dim RecCnt As Integer
    Set dbs = CurrentDb()
    Set rs1 = dbs.OpenRecordset("LogRem")
    Set rs2 = dbs.OpenRecordset("qryTmpRem1")
    RecCnt = 0
    On Error GoTo Dberror

    rs2.MoveFirst
    Do Until rs2.EOF
    If rs2.Notify <> 0 Then
    With rs1
    .AddNew
    !Week = rs2.Week
    !LogonID = rs2.LogonID
    !MessSent = Me.txtMessDate2
    !MessNbr = rs2.MessNbr
    !Period = rs2.Period
    !Reason = rs2.Reason
    !Associate = rs2.Associate
    !AdmMgr = rs2.AdmMgr
    !SchHrs = rs2.SchHrs
    !ActHrs = rs2.ActHrs
    !AdmLvl = rs2.AdmLvl
    !Notify = rs2.Notify
    !NOTcd = rs2.NOTcd
    .Update
    .Clone
    End With
    Dim strMess As String
    strAssEmail = rs2.eMail
    strMgrEmail = rs2.MgrEmail
    strBccEmail = "bccName@yahoo.com"
    strGreeting = rs2.Greeting
    strMessNbr = rs2.MessNbr
    strPeriod = rs2.Period
    strAssociate = rs2.Associate
    strSchHrs = rs2.SchHrs
    strActHrs = rs2.ActHrs
    strSubj = "RMP" & strMessNbr & " Reminder to: " & strGreeting
    strMess = "Associate Name: " & [strGreeting] & Chr$(13) & Chr$(13) _
    & "Reporting Period: " & [strPeriod] & Chr$(13) & Chr$(13) _
    & "Scheduled Hours: " & [strSchHrs] & Chr$(13) & Chr$(13) _
    & "Hours Recorded: " & [strActHrs] & Chr$(13) & Chr$(13) _
    & Chr$(13) & Chr$(13) _
    & rs2.L01 & Chr$(13) _
    & rs2.L02 & Chr$(13) _
    & rs2.L03
    DoCmd.SendObject , , _
    acFormatRTF, _
    strAssEmail, _
    strMgrEmail, _
    strBccEmail, _
    strSubj, _
    strMess, False, False

    RecCnt = RecCnt + 1
    End If
    rs2.MoveNext
    Loop
    rs2.Close

    Requery

    MsgBox RecCnt & " First Reminders Sent. ", vbInformation

    ' DoCmd.Close
    ' Forms.frmMainMenu.Visible = True

    CurrentDb.Execute "DELETE * FROM tmpRem1;"
    Requery
    Exit Sub

    Dberror:
    If Err = 3021 Then
    MsgBox "There are no messages to send. "
    DoCmd.Close
    Forms.frmMainMenu.Visible = True
    Else

    MsgBox "There was an error adding the record." _
    & Err.Number & ", " & Err.Description
    End If
    End Sub

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Change this:

    strBccEmail;"bcc2Name@Yahoo.com",

    to this

    strBccEmail & ";bcc2Name@Yahoo.com",

  3. #3
    jhrBanker is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    68

    Thanks

    Thanks. I think that did it. No compile error now.
    Thanks again.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA Send Email using DoCmd.SendObject
    By malamute20 in forum Programming
    Replies: 15
    Last Post: 10-05-2011, 12:44 PM
  2. Replies: 1
    Last Post: 11-17-2010, 11:24 AM
  3. Replies: 2
    Last Post: 08-17-2010, 10:54 AM
  4. Email sent via DoCmd.SendObject
    By silverback in forum Programming
    Replies: 0
    Last Post: 10-29-2009, 06:26 AM
  5. DoCmd.SendObject Help
    By bgreer5050 in forum Programming
    Replies: 0
    Last Post: 01-12-2007, 06:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums