# Send an email when an Appointment reminder fires

Last reviewed on December 30, 2013

Another entry in my Lazy Programmer Series, this time I have a macro that sends an email message when a reminder fires. This macro was the result of a request for the ability to send messages to the sales team each morning with the day's agenda.

If you prefer to use an add-in, I have a list of reminder tools at Calendar Tools for Outlook

You can use the macro to send yourself reminders or even to compose an email message ahead of time (in the body of a an appointment form) and send it later. Outlook will need to be running and be able to connect to the mail server for the message to be generated and sent.

Because the message is composed when the reminder fires, the message time stamp will be the reminder time. Please don't abuse the trust others have in you: use this macro for legitimate purposes, not to convince someone you were working when you weren't!

Outlook needs to be running for these macros to work. Note, this will trigger the email security alert in older versions of Outlook. Use one of the tools listed at the end to dismiss the dialogs.

To use, press Alt+F11 to open the VBA editor then copy the code and paste it into ThisOutlookSession.

## Send a message to someone when a reminder fires

This macro checks for Appointment reminders and sends a message to the value in the location field. For this to be useful, you need to use a category, otherwise Outlook will attempt to send a message with every appointment reminder.


Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)

If Item.MessageClass <> "IPM.Appointment" Then
Exit Sub
End If

If Item.Categories <> "Send Message" Then
Exit Sub
End If

objMsg.To = Item.Location
objMsg.Subject = Item.Subject
objMsg.Body = Item.Body
objMsg.Send

Set objMsg = Nothing
End Sub

To use a template instead of the default message form, replace Set objMsg = Application.CreateItem(olMailItem) with Set objMsg = Application.CreateItemFromTemplate("C:\path\to\test-rule.oft")

## Send a message to yourself when a reminder fires


Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem

Set objMsg = Application.CreateItem(olMailItem)

objMsg.To = "alias@domain.com"
objMsg.Subject = "Reminder: " & Item.Subject

' Code to handle the 4 types of items that can generate reminders
Select Case Item.Class
Case olAppointment '26
objMsg.Body = _
"Start: " & Item.Start & vbCrLf & _
"End: " & Item.End & vbCrLf & _
"Location: " & Item.Location & vbCrLf & _
"Details: " & vbCrLf & Item.Body
Case olContact '40
objMsg.Body = _
"Contact: " & Item.FullName & vbCrLf & _
"Phone: " & Item.BusinessTelephoneNumber & vbCrLf & _
"Contact Details: " & vbCrLf & Item.Body
Case olMail '43
objMsg.Body = _
"Due: " & Item.FlagDueBy & vbCrLf & _
"Details: " & vbCrLf & Item.Body
objMsg.Body = _
"Start: " & Item.StartDate & vbCrLf & _
"End: " & Item.DueDate & vbCrLf & _
"Details: " & vbCrLf & Item.Body
End Select

objMsg.Send
Set objMsg = Nothing
End Sub



## Select an appointment and send a message

With a few tweaks, the macro above can be used to send a message by selecting the appointment then running the macro.

1. Press Alt+F11 to open the VBA editor.
2. Right click on Project1 and choose Insert > Module.
3. Paste the code below into the Module.
4. Get the GetCurrentItem function from Outlook VBA: work with open item or selected item and paste it into the module.

Public Sub App_Reminder()
Dim Item As AppointmentItem
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)

Set Item = GetCurrentItem()

With objMsg
'  .To = Item.Location
.Subject = Item.Subject
.Body = Item.Body
.Display ' use .Send to send it instead
End With

Set objMsg = Nothing
Set Item = Nothing

End Sub


Pop up a dialog

You can use the code on this page to do pretty much anything VBA can do when the reminder fires.

This simple code sample displays a dialog box to remind you.

Private Sub Application_Reminder(ByVal Item As Object)

If Item.MessageClass <> "IPM.Appointment" Then
Exit Sub
End If

MsgBox "You have an appointment for " & vbCrLf _
& Item.Subject & vbCrLf _
& "on " & Format(Item.Start, "mmm dd") & vbCrLf _
& "Time: " & Format(Item.Start, "hh:mm AM/PM") _
& vbCrLf & "Location: " & Item.Location

End Sub