I use this public function:
Which is called out in this sub routine:
My question is "How Would I send this as BCC: only"?
Tried changing the strSendto string to strBCCLine string in all instances and all that happens is a blank email.
Code:
Public Function SendAnEmail(olSendTo As String, _ olSubject As String, _ olEMailBody As String, _ olDisplay As Boolean, _ Optional olCCLine As String, _ Optional olBCCLine As String, _ Optional olOnBehalfOf As String, _ Optional olAtchs As String, _ Optional SendAsHTML As Boolean) As Boolean On Error GoTo EH Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim strArray() As String Dim intAtch As Integer Set olApp = CreateObject("Outlook.Application") Set olMail = olApp.CreateItem(olMailItem) With olMail .To = olSendTo .subject = olSubject If SendAsHTML Then .BodyFormat = olFormatHTML .HTMLBody = olEMailBody Else .body = olEMailBody End If .CC = olCCLine .BCC = olBCCLine .SentOnBehalfOfName = olOnBehalfOf strArray = Split(olAtchs, "%Atch") For intAtch = 0 To UBound(strArray) If FileExists(strArray(intAtch)) Then _ .Attachments.Add strArray(intAtch) Next intAtch If olDisplay Then .Display Else .Send End If End With Set olMail = Nothing Set olApp = Nothing SendAnEmail = True Exit Function EH: MsgBox "There was an error generating the E-Mail!" & vbCrLf & vbCrLf & _ "Error: " & Err.Number & vbCrLf & _ "Description: " & Err.Description & vbCrLf & vbCrLf & _ "Please contact your Database Administrator.", vbCritical, "WARNING!" SendAnEmail = False Exit Function End Function
Code:
Private Sub btnGroupEmail_Click() On Error GoTo EH Dim strSendTo As String Dim strSubject As String Dim strEMailBody As String Dim strCCLine As String Dim strBCCLine As String Dim strOnBehalfOf As String Dim MyDB As DAO.Database Dim rstEMail As DAO.Recordset Dim strEMail As String DoCmd.SetWarnings False DoCmd.OpenQuery "qryEmail", acViewNormal DoCmd.SetWarnings True Set MyDB = CurrentDb Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail", _ dbOpenSnapshot, dbOpenForwardOnly) With rstEMail If Not (.BOF And .EOF) Then Call .MoveFirst Do While Not .EOF 'Build the Recipients String strSendTo = _ strSendTo & _ IIf(strSendTo = "", _ "", _ ";") & !Email Call .MoveNext Loop End If Call .Close End With Call MyDB.Close Set rstEMail = Nothing Set MyDB = Nothing 'Generate and Display the E-Mail Call SendAnEmail(olSendTo:=strSendTo, _ olSubject:=strSubject, _ olEMailBody:=strEMailBody, _ olDisplay:=True, _ SendAsHTML:=True) Exit Sub EH: MsgBox "There was an error sending mail!" & vbCrLf & vbCrLf & _ "Error: " & Err.Number & vbCrLf & _ "Description: " & Err.Description & vbCrLf & vbCrLf & _ "Please contact your Database Administrator.", vbCritical, "WARNING!" Exit Sub End Sub
Tried changing the strSendto string to strBCCLine string in all instances and all that happens is a blank email.
Comment