Hi All,
I need to send birthday wish to members whom birthday occurs on the current date. In order to get members birthday on the current date i have a query "qryHappyBirthday" with Sql:
SELECT Members.MembershipType, Members.MembershipTitle, Members.MemberID, Members.SurName, Members.GivenName, Members.GenderStatus, Members.DesignationSOC, Members.Dob, Members.PlaceOfBirth, tblContactNumbers.TelephoneResidence, tblContactNumbers.MobileNo1, tblElectronicContacts.MemberEmail
FROM (Members INNER JOIN tblContactNumbers ON Members.MemberID = tblContactNumbers.MemberID) INNER JOIN tblElectronicContacts ON Members.MemberID = tblElectronicContacts.MemberID
WHERE (((Month([Dob]))=Month(Date())) AND ((Day([Dob]))=Day(Date())));
I have got a module "mod_EmailOutlook" with code:
Option Compare Database
Option Explicit
Sub EmailOutlook()
'strive4peace
'use early binding to develop
' Dim appOut As Outlook.Application _
, oMsg As Outlook.MailItem
'use late binding to deploy
Dim appOut As Object _
, oMsg As Object
Dim sPathFileAttachment As String _
, sSubject As String _
, sBody As String _
, sMailTo As String
sMailTo = "someone@..." '<=== I NEED HERE EMAIL ADDRESSES TO BE FILLED ON THE RESULTS OF
' "qryHappyBirthday"
sSubject = "Happy Birthday"
sBody = "Your message..."
sPathFileAttachment = "C:\Users\tanwe\Desktop\Today for sending email.txt" 'or whatever this is '<== This is ' an example, i may attach here some image.
'sPathFileAttachment = "c:\path\file.ext" 'or whatever this is
Set appOut = CreateObject("Outlook.Application")
Set oMsg = appOut.CreateItem(0) '0=olMailItem
With oMsg
'.Importance = olImportanceHigh
.To = sMailTo
'.CC = "cc email address"
'.BCC = "cc email address"
.Subject = sSubject
.Body = sBody
If sPathFileAttachment <> "" Then
.Attachments.Add sPathFileAttachment
End If
' If you want to edit before sending
.Display
'otherwise, to just send without looking...
'.Send
End With
Proc_Exit:
On Error Resume Next
'release object variables
Set appOut = Nothing
Set oMsg = Nothing
Exit Sub
Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " EmailOutlook"
Resume Proc_Exit
Resume
End Sub
~~~~~~~~~~~~~~~~
Above module after pressing F5 key works perfect, it opens Outlook. I've tested it by putting my own email address and sending and received mail send from Outlook.
I assume (May be i'm wrong) there must be something like DO WHILE EOF and LOOP in the above code, but i have no knowledge in Access/VBA about this.
When all this is set, how i will call this module to run ?. I need to put a button on my Continuous form "Notification3" to call this module. This form displays the output of query "qryHappyBirthday"
Help required please.
Regards,
Khalid
Posted by: khalidtanweerburrah@yahoo.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (1) |
Tidak ada komentar:
Posting Komentar