Send a greeting message to a contact on birthday

Post number 5 has been selected as the best answer.

gaib

New Member
Outlook version
Outlook 2016 64 bit
Email Account
POP3
I found this macro which seems to be reasonably close to what I'm looking for.


My question! How can I just run this macro when I want and it searches the calendar for any birthday's on that particular day?

I don't really want to setup a task for this to fire automatically.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I have this macro which creates deferred messages - it could easily be tweaked to look for b-days 'today' and send the message.
 

gaib

New Member
Outlook version
Outlook 2016 64 bit
Email Account
POP3
Hi Diane and thank you for the help. I was able to get this macro to work by selecting the contact and running the macro, but if not to much trouble, I would love to know how to loop thru the "today" birthday's and display versus send.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
looping the folder is easy - but if you have many contacts, filtering the dates would be faster than looping each contact. I'll take a look at it.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This will loop through each contact and check for an upcoming birthday then prepare a birthday email that will be sent the morning of their birthday.

Code:
Public Sub SendDeferredBirthdayGreetings()

Dim bday

Dim objOL As Outlook.Application
    Dim objItems As Outlook.Items
    Dim objFolder As Outlook.MAPIFolder
    Dim obj As Object
 
    Set objOL = Outlook.Application
    Set objFolder = objOL.ActiveExplorer.currentFolder
    Set objItems = objFolder.Items
 
    For Each obj In objItems


If TypeName(obj) = "ContactItem" Then

 Set oContact = obj
'uses "this" year
 bday = DateSerial(Year(Now), Month(oContact.Birthday), Day(oContact.Birthday))
 
 ' check for upcoming birthdays this week
If bday > Date + 1 And bday < Date + 7 Then
 Debug.Print bday

' check for email address
If oContact.Email1Address = "" Then GoTo nextrecord

 bday = bday + 0.25 ' sets it for 6 am the day of the birthday

Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)

  objMsg.To = oContact.Email1Address
  objMsg.Subject = "Happy Birthday"
  objMsg.Body = "Hope your day is a happy one!"

  objMsg.DeferredDeliveryTime = bday

  'displays the message form so you can enter more text
  objMsg.Display
 
  'use this to send to outbox
  'objMsg.Send

  Set objMsg = Nothing
End If

End If

nextrecord:
Next
End Sub
 

gaib

New Member
Outlook version
Outlook 2016 64 bit
Email Account
POP3
This is perfect Diane. Thank you very much.
 
Similar threads
Thread starter Title Forum Replies Date
T Outlook creates a copie of every mail I send Using Outlook.com accounts in Outlook 4
R How to restrict GWSMO sync to Outlook Send/Receive cycles Using Outlook 0
pwatts2 Restrict some lists to only BCC send option Outlook Wishlist 2
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
glnz O365 - How to send from acct 2 but showing email name from acct 1 as From - alias? Using Outlook 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
C Synchronizing subscribed folders causes hanging during send/receive process Using Outlook 2
M Extract all links from Outlook email, send to Excel Using Outlook 2
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
T After I send a new email, it remains in the Draft folder Using Outlook.com accounts in Outlook 3
B Programmatically force html send and insert clipboard contents into body Outlook VBA and Custom Forms 0
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
M ERROR: None of your email accounts could send to this recipient Using Outlook 2
C Send/receive error 80040119 Using Outlook 2
J Send Again NDR Outlook VBA and Custom Forms 1
J Add an Attachment Using an Array and Match first 17 Letters to Matching Template .oft to Send eMail Outlook VBA and Custom Forms 2
ChrisK2 Send email to advertise@slipstick.com fails: "The group advertising isn't set up to receive messages from..." Using Outlook 3
B resend if no reply and send an automatic reminder Outlook VBA and Custom Forms 0
F Send As a Gmail account via outlook Web Using Outlook 3
R auto send email when meeting closes from a shared calendar only Outlook VBA and Custom Forms 2
X Unable to send an email from one account to another on same PC Using Outlook 2
S Meeting Invite arrives from Wrong ("send-as") Sender Using Outlook 1
M VBA to send reminder email if no response Using Outlook 13
D Using a VBA Custom Form to Send Reoccurring Email Upon Task Completion Outlook VBA and Custom Forms 4
M Can't send email in outlook.com Using Outlook 9
R Can't Send calendar share invite Using Outlook 5
R Can't send messages to groups in Outlook Using Outlook 2
J Updating existing entry on shared calendar wants to send update from delegate Using Outlook 0
M Send/Receive error 0x800CCC0F Using Outlook 0
soadfan Outlook won't send e-mail when offline Outlook VBA and Custom Forms 19
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3
N Outlook 2010 will not send nor receive Using Outlook 4
I Outlook 2013 Send problem - 'Not Responding' forever Using Outlook.com accounts in Outlook 10
K Delay Send and Mail Merge Outlook VBA and Custom Forms 4
A Capturing Send Variables without using Application_ItemSend in ThisOutlookSession Outlook VBA and Custom Forms 8
A Outlook - Send New 20 Attachments through Email Using Outlook 4
L Outlook 2007 Separate the Send/Receive functions Using Outlook 2
S Send email via SMTP - use transport rules to add to senders inbox (then rule to move to sent items Exchange Server Administration 1
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
L How to automaticlly Send/Receive every 3 mins but override send if send/receive is pressed Using Outlook 2
D Delay Send not working Using Outlook 3
F Send multiple batch tasks to single person Using Outlook 3
R Prompt asking the user to send email to folder as *.msg file Outlook VBA and Custom Forms 1
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1
D Default Send Account that Works? Using Outlook 0
D Outlook.com in Outlook 2016 Trys & Fails to Send on Behalf of Itself Using Outlook.com accounts in Outlook 2

Similar threads

Top