Unanswered: Send email from outlook 2013 using access 2016
I am really hoping to get some guidance from the gurus here. I have done a lot of research on this issue and found codes but none of them are working for me.
Let me explain:
I would like to send customized email (BCC) to multiple recipients using outlook by simply clicking a button. I have a query that filters monthly birthdays and displays them in report.
what code do I need that will use outlook to send email to those recipients wishing them a happy birthday?
This is my query to filter out monthly birthdays.
SELECT DISTINCTROW Members.*, MemberTypes.MemberType AS MemberTypeDesc, Members.Status
FROM MemberTypes INNER JOIN Members ON MemberTypes.MemberTypeID = Members.MemberType
WHERE (((Members.Status)="Active") AND ((Month([Birthdate]))=Month(Now())));
in a form you have a listbox
this listbox is tied you your query above showing those having bdays to send to. name , email
put a button on the form to execute email send.
when user clicks the button, it scans the list gets email and sends text....
Public Sub ScanAndEmail()
Dim vTo, vSubj, vBody, vRpt
dim i as integer
For i = 0 To lstEAddrs.ListCount - 1
vRpt = lstEAddrs.ItemData(i)
lstEAddrs = vRpt
vTo = lstEAddrs.Column(2)
vBody = "body of email"
vSubj = vRpt
vFilePath = "" 'path of the snapshot or XL or PdF
Call Email1(vTo, vSubj, vBody)
'YOU MUST ADD THE OUTLOOK APP IN REFERENCES!!! checkmark OUTLOOK OBJECT LIBRARY in the vbE menu, Tools, References
Public Function Email1(ByVal pvTo, ByVal pvSubj, ByVal pvBody,optional ByVal pvFile) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
.To = pvTo
.Subject = pvSubj
.Body = pvBody
If Not Ismissing(pvFile) Then .Attachments.Add pvFile, olByValue, 1
EmailO = True
Set oMail = Nothing
Set oApp = Nothing
MsgBox Err.Description, vbCritical, Err