Sending Email from a form

pld60

Registered User.
Local time
Today, 09:06
Joined
Mar 22, 2016
Messages
20
I have a form that sends emails with the On_Click Event of a command button using this code.

Code:
Private Sub Confirm_Click()
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strbody As String
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
On Error Resume Next
    With OutMail
    .Body = "Thank you for accepting a Transport on" & vbNewLine & Me.TBtransportdate.Value _
    & " at " & Me.TBtransporttime.Value & " for " _
    & Me.TBDuration.Value & " Hours." & vbNewLine & "Transport # " _
    & Me.TBID.Value & vbNewLine & "There will not be a reminder about this transport."
 
    .Subject = "Confirmation of Transport"
    .To = DLookup("Email", "TBLCasualStaff", "Staff = '" & Me.CBStaff1.Value & "'")
    .BCC = DLookup("Email", "TBLCasualStaff", "Staff = '" & Me.CBStaff2.Value & "'")
 
.Send
 
   End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
     DoCmd.Close
End Sub

This works well accept It would be helpful if those receiving the emails could not see the others email address. How do I send more than one BCC?
 
.BCC = "email1;email2;email3"
 
arnelgp,

Thank you for the reply. I have tried that but am confused as to how to structure BCC. "email1;email2;email3" When I am working with DLookup to get the emails from a table.
 
Concatenate the email addresses. If you only have 2 (as per your example)
strBCC= dlookup(....) & ";" & dlookup(....)

If you have multiple, put the concatenation in a loop
for i = 1 to intNumEmailAddresses
strBCC= strBCC & ";" & dlookup(...) 'Or loop through a recordset
next i
 

Users who are viewing this thread

Back
Top Bottom