Sub SendBirthdayMessage()
Dim olkContacts As Outlook.Items, _
olkContact As Object, _
olkMsg As Outlook.MailItem
Set olkContacts = Session.GetDefaultFolder(olFolderContacts).Items
For Each olkContact In olkContacts
If olkContact.Class = olContact Then
If (Month(olkContact.Birthday) = Month(Date)) And (Day(olkContact.Birthday) = Day(Date)) Then
Set olkMsg = Application.CreateItem(olMailItem)
With olkMsg
.Recipients.Add olkContact.Email1Address
'Change the subject as needed'
.Subject = "Happy Birthday " & olkContact.FirstName
'Change the message as needed'
.HTMLBody = "ICD wanted to wish you a Happy Birthday Today!!!"
'Change Display to Send if you want the messages sent automatically'
.Send
End With
End If
End If
Next
Set olkMsg = Nothing
Set olkContact = Nothing
Set olkContacts = Nothing
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…