Hello everyone I am new to programming in VBA and have been at it for a week. I am trying to learn to write my own code but I have come up with a issue.
My end result is that I send one email to all my vendors with their names in the BCC field. My current code creates a email for each contact which is not needed. I am sure this is a simple fix but here is my code so far. I appreciate your help!
Private Sub Compose_Button_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.mailItem
Dim objOultlookRecip As Outlook.Recipients
Dim objOutlookAttach As Outlook.Attachments
Dim TheAddress As String
Set db = CurrentDb
Set rst = Me.Recordset
rst.MoveFirst
Set objOutlook = CreateObject("Outlook.Application")
Do Until rst.EOF
'Create Email message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
TheAddress = rst![E-Mail]
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add(TheAddress)
objOutlookRecip.Type = olBCC
objOutlookMsg.Display
End With
rst.MoveNext
Loop
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
Thank you!!