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