If you hope that Outlook can automatically send a greeting message to the contact when his birthday is today, you can use the method introduced in this article.
Many users are accustomed to sending greeting messages to the contacts on their birthdays. Without any doubts, if you check the contacts’ birthdays and send the greeting emails manually, it will be a very tedious task. Therefore, why don’t you let Outlook automatically do it for you? Although Outlook doesn’t provide such a native feature, you still can generate it with VBA. Therefore, in the followings, we will expose the elaborate steps and VBA codes to you.
Auto Send a Greeting Message to the Contact When His Birthday Is Today
- At the very outset, launch your Outlook program.
- Then in the main Outlook window, press “Alt + F11” key shortcuts to access Outlook VBA editor.
- Next you ought to open the “ThisOutlookSession” project.
- Subsequently, you need to copy the following VBA codes into this project.
Private Sub Application_Reminder(ByVal Item As Object) Dim objContacts As Outlook.Items Dim objItem As Object Dim objContact As Outlook.ContactItem Dim strToday As String Dim strBirthday As String Dim objGreetingMail As Outlook.MailItem Dim objWordDocument As Word.Document If TypeOf Item Is TaskItem And Item.Subject = "Send Birthday Greeting Mail" Then strToday = Month(Date) & "-" & Day(Date) Set objContacts = Outlook.Application.Session.GetDefaultFolder(olFolderContacts).Items For Each objItem In objContacts If TypeOf objItem Is ContactItem Then Set objContact = objItem strBirthday = Month(objContact.Birthday) & "-" & Day(objContact.Birthday) If strBirthday = strToday Then 'Create the greeting message from a preset template Set objGreetingMail = Outlook.Application.CreateItemFromTemplate("C:\Users\Test\Documents\UserTemplates\Birthday Greeting Mail.oft") Set objWordDocument = objGreetingMail.GetInspector.WordEditor objWordDocument.Range.InsertBefore "Dear " & objContact.LastName & vbCrLf & vbCrLf 'To create a new mail, you can also use: 'Set objgreetingmail = outlook.Application.CreateItem(olMailItem) With objGreetingMail .Recipients.Add (objContact.Email1Address) .Subject = "Happy Birthday!" .Display 'To directly send .Close (olSave) .Send End With End If End If Next End If End Sub
- After that, you need to sign this code.
- Later exit the VBA editor.
- Then you should create a recurring task with a recurring reminder.
- The task subject should be set to “Send Birthday Greeting Mail”.
- Enable a “Daily” recurrence in the task.
- Set a reminder for the recurring task
- After getting such a task, you should proceed to change your Outlook macro settings to ensure digitally signed macros are permitted.
- From now on, every time the reminder alerts, the macro will run immediately. Outlook will auto send out the greeting mail to the contact whose birthday is today.
Prevent Miserable PST Data Loss
In order to avoid the pain from PST data loss, you should spend a lot of time and energy preventing PST corruption. For instance, you should develop a good habit of closing Outlook properly and backing up your PST file on a periodical basis. In addition, it is also recommended to get hold of a reputable and powerful fix tool, such as DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair SQL Server and outlook repair software products. For more information visit www.datanumen.com