Last reviewed on April 27, 2015   —  128 Comments

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.BCC = "me@slipstick.com"
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



Tools

#### More Information

Open a webpage when a Task reminder fires
To send an email daily using a Task, see E-Mail: Send daily (vboffice.net)

Discuss in our community

1. ROGER BERTRAND says

I have a question: how does this run?

Once it is copied into the OUTLOOK SESSION as indicated, is every REMINDER going to generate an EMail? For example I have various AGENDA ITEMS as I program all my activities in OUTLOOK and they all have a reminder that pops up in the REMINDER WINDOW, will I receive a REMINDER Email for all of these?

Additionally, would it be possible to make it AGENDA ITEM specific, ie. for AGENDA ITEM with POP UP REMINDER one could elect to ALSO get an Email REMINDING of the AGENDA ITEM.

Roger Bertrand, P. Eng.

• Diane Poremsky says

It runs when the reminders fire - the two IF statements provide the filtering. If Item.MessageClass <> "IPM.Appointment" tells it to only run for appointment reminders. If Item.Categories <> "Send Message" tells it to only run if the appointment's category is set to 'send message'.

The second macro runs for all reminders - but its purpose is to send your reminders to you by email. You could use categories to filter this too.

2. ROGER BERTRAND says

Ok. Thanks. Is there a way to assign the REMINDER FIRING specifically to a particular agenda item?I have all teh AGENDA ITEMS with notification so they pop up in the notification window and there I track them. Now some of these I would like to receive a REMINDER EMAIL so I could assign it a FOLLOW UP and PRIORITY. Is this feasible?

As I understand this VBA code, it would send me an EMAIL for all the AGENDA ITEMS I have setup since they all have a NOTIFICATION REMINDER in my case, correct or wrong?

3. ROGER BERTRAND says

Please let me rephrase my question: all my agenda items have a category and all have a reminder so they pop up in the notification window. Therefore under this scheme would I reeceive an Email reminder?

Secondly, fi I wanted to make this process selcetive, that is for a specific agenda Item I would like that in addition to the Pop Up Reminder I would receive a Reminder Email, can that be done?

Thanks,

Roger

• Diane Poremsky says

Yes, if the category used on the agenda is the one configured in the VBA, you would receive an email when the reminder fires.

On #2, you'll always get both the standard reminder window and send the email.

4. ROGER BERTRAND says

Please let me ask you if this would work: if I want only some messages to have an Email fired to me, would it work if I created a new category, say "Send EMail", and then set this category along with any other category to items I would like to have an Email sent to me?

Where would I insert that code so only those I want a reminder Email are fileterd through that catefory:

If Item.Categories = "Send Email" Then

I assume I could do the same on the first VBA to ahve only Items flagged with the "SEND EMAIL" category fire the EMail Reminder?

Thanks ,

Roger

PS: excuse my low level knowledge of VBA, I am not that trained to using VBA with OUTLOOK. I use a lot more with EXCEL.

• Diane Poremsky says

Yes, that is how it works.

As an FYI, the code as written only works with one category per item - you can't assign two categories to the task. It's a bit more complicated to look in the category string for a word or phrase.

5. A Clark says

I created this macro and it seemed to work the first week, but on subsequent weeks, the email is not going out. I checked and the code is still there. The Category is set to Send Message and is the only category. But I do have multiple email addresses separated by semicolons in the Location field.
I am using Windows 7 and Office 2007 if that makes a difference.
Can you suggest a place to begin further troubleshooting?
Thank you.

• Diane Poremsky says

First, check the macro security level. Is it on 'none' or warn for all macros? If the macro is not signed, you need to use one of those security levels.

• Naresh says

Hi,

I tried running the above query in vbeditor but none of the above macros aer working. I changed macro settings too. Other macros that I have created are working. Please help

• Diane Poremsky says

The macros that are reminder macros only run if the conditions are met - the item is an appointment and (in the first macro) the category matches.

6. Curtis H says

The following is a code i got working to send me an email when a reminder fires however it does not include any details about the reminder....Can you help?? thanks so much

Private Sub Application_Reminder(ByVal EventItem As Object)

Dim MailMsg As MailItem

Set MailMsg = Application.CreateItem(olMailItem)

If EventItem.MessageClass = "IPM.Appointment" Then

Call SendApptMail(MailMsg, EventItem)

End If

Set MailMsg = Nothing

End Sub

Sub SendApptMail(Mail_Item As Object, Appt_Item As Object)

Mail_Item.To = "email@email.com"

Mail_Item.Subject = "Reminder Time Off"

Mail_Item.HTMLBody = "Just a reminder that in the near future someone has requested a day off. Thank You"

Mail_Item.Send

End Sub

• Diane Poremsky says

you need to get the details from the appointment - it would look something like this: mail_item.htmlbody = "your text" & appt_item.body & appt_item.startdate

7. Howard Hendra says

Hello I want to start off by saying by no means am I knowledgable with VB. I am trying to set it up as described, but one of the things I find confusing is why would one want to send it back to your own e-mail account. I tried to alter the code with my text pager e-mail address and I get a complie error everytime the reminder pops up. I appreaciate any help you can offer. Thanks Howard

• Diane Poremsky says

Most people use it to send reminders to cell phones. compile error usually means the code is not right. Are the colors in the VBA editor similar to the ones on the page? Open the VBA editor and look at the code - is a line yellow?

8. Howard Hendra says

Ok it works. I was copying and pasting inproperly. One problem I do have though is I get the following message- "A program is trying to access E-Mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No" Allow access for 1 thru 10 mimutes. I want to say thanks for getting back to me so fast and also say thanks for your code. Howard

• Diane Poremsky says

You'll need to use one of the apps in the tools section to bypass the security dialog.

9. Howard Hendra says

Thank you for your help, but its not going to work for me . IT gives me no control over the computer whatsoever. I am even surprised that I was able to execute the vb code without permission from god himself. It's ashame cause they wont get me a smart phone, and I am simply too busy out in the field to remember every meeting or appointment. I was so pysched when it ran that I would have actually been able to do something to make myself more productive. Thanks for the help. Howard

10. M Burnett says

I have implimented your send an email and open web page task VBA and have the page opening and the task emailed. What I would like to have happen is to have the opened page sent via email with the opened page in the body of the email. Can this be done?

• Diane Poremsky says

It should be possible but i don't have any code samples. IE doesn't expose the send page by email command (http://msdn.microsoft.com/en-us/library/ms970456.aspx) so you'll need to use windows scripting - probably copy the page then use it as item.body.

11. Kirld says

Hi Diane,

Would it be possible to edit the code so that when every reminder fires up, and email alert will be sent also to the attendees of the meeting for example?

• Diane Poremsky says

Should be able to. In the first example, you'd add something like this to the code:
objMsg.To = Item.Recipients

• Diane Poremsky says

Actually, you'll need to do it this way

For Each Recipient In Item.Recipients
strRecip = strRecip & ";" & Recipient.Address
Next Recipient

objMsg.To = strRecip
Item.Recipients.Resolve

12. Shane Brewer says

Hi Dianne,

A bit off topic, but is there a way that I could create an email containing similar information to your example but attach the macro to a button in the toolbar so that I can select the appointment, push the button and it will generate the email?

• Diane Poremsky says

If it's a meeting, I have a sample at Send message to attendees

For appointments, I added a new code sample to the bottom of the page that does this.

13. Shane Brewer says

Thanks Dianne,

I have that working fantastically. Just one other thing... Everything works now as long as I have the appointment either open or selected. But at the moment it only works if the appointment is selected in the main calendar window. Is there a way to have it work if the required appointment is selected in the to-do bar?

• Diane Poremsky says

I will check into it. It's something that i never thought about.

14. Shane Brewer says

Thanks Dianne,

Much appreciated.

15. Stewart Aitken says

Hello Diane

I am trying to use your macro but it didn't work, so I'd like to check what I have done wrong! I copied and pasted your macro into Outlook ThisSessionOutlook and saved it. I then created an Appointment in Outlook Calander with the location as my own email address. The reminder pops up but there is no email sent to my address. Any idea what I did wrong?

Cheers
Stewart

• Diane Poremsky says

Did you check macro security settings?

16. Shane Brewer says

Did you have any luck with this Diane? I have hit a wall with this one.

• Diane Poremsky says

It should work when you select an appointment in the to-do bar - the last macro on the page works on the select appt in the to-do here.

What exactly happens?

17. Shane Brewer says

If the Calendar is the active window and an appointment is selected in the To-Do bar the following error is received:-

Run-time error '91':

Object variable or With block variable not set

If any other window is active (Mail, Contacts, Tasks etc) and an appointment is selected in the To-Do bar the following error is received...

Run-time error '13':

Type mismatch

Hopefully that will give some insight into where I am going wrong.

• Diane Poremsky says

It's the GetCurrentItem that is kicking up the error - it worked for me the other day, but i don't recall if i used the code on the page or a variation that did not include the getcurrentitem function.

Ah... i know what i did - when i run the macro from the VB editor, it works because focus remains on the selection in the to-do bar. When i do it from outlook, the selection loses focus. I added the macro to the Calendar Tools / appointment ribbon and it works - the appt doesn't lose focus.

18. Stewart Aitken says

Hello Diane. I wouid like to use an Add-in that checks for Appointment reminders and sends a message to the address in the location field or another field. So not to my own email address. After looking at the Add-Ins using the link, I can't see one that seems to do this. They seem to only send emails reminders to the event organiser. Can you suggest an Add-In? Thanks, Stewart.

• Diane Poremsky says

I believe for that you will need to use a macro, not an addin.

19. Akiva Fleischmann says

Hi - I'm sort of a newbie at this stuff. Your code is very helpful, I'm sure, and thank you - but I'm not sure exactly where in the code I enter the pertinent details? Let me give you an example. Let's say I want to write an email to akivaf@gmail.com every day with the subject "Test" and the body, "If this works, then the macro worked." The appointment on my calendar will be every day at 8:00 AM, and I made the category "Test" which I have placed it in. Given those instructions, can you please tell me EXACTLY what to do, maybe paste the code with my pertinent details in it so I can know what to do? THANK YOU SO MUCH in advance!

• Diane Poremsky says

See How to use the vba editor - you'll paste this code in ThisOutlookSession. Macro security needs set to low for testing.

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 <> "Test" Then Exit Sub End If With objMsg ' Email addresses go here, use semi-colons to separate multiple addresses .To = " akivaf@gmail.com" .Subject = "Test" .Body = "If this works, then the macro worked." ' use .display to view but not automatically send .Send End with 

 Set objMsg = Nothing End Sub

20. Akiva Fleischmann says

Also, I have Outlook 2013, does that change anything? Also, what if I want to send to multiple email addresses?

• Diane Poremsky says

This macro works with Outlook 2013 too.

21. Shane Brewer says

Sorry Diane, you lost me. How would I add the macro to the Calendar Tools/Appointment Ribbon?

• Diane Poremsky says

The same way it's done for other ribbons. :) Select tools on the right of the Customize ribbon dialog, add a group, then add the macro to it. quickie video: http://www.screencast.com/t/irNBqMiNkPu

22. juriy maksimov says

It is essential that the script sent a reminder of the meeting to all those listed in the "To" field and how to do it I do not know (

• Diane Poremsky says

Sounds like this script: Send an email to attendees is what you need. If you need to send to everyone, you can do that from the meeting - there is an option to send an email to all invitees.

23. Mike says

Works like a charm. You are amazing! Thank you.

24. Mike says

This worked perfectly on the first day but hasn't since (4 days). OL14.06 x32 on W7 SP1 x64. Any suggestions?

• Diane Poremsky says

What is your macro security set to? That is the usual cause of macros not working properly. You can also change .send to .display so you can see the opened message, it beats checking the sent folder. :)

25. Mike says

You got it. I never thought to check the security as it worked fine the first day without touching the macro security. Restarting Outlook enforced the security. Kinda odd. Thanks again.

26. Mike says

And... I even figured out how to easily digitally sign this code so I could return the security setting to the highest possible. Thanks again!

27. Jacqueline says

THANK YOU! You're wonderful! Also, an easy way to send to multiple addresses ... you can simply create a group list in your contacts and type the group name in the location field. Works perfectly.

28. mozzis says

Thanks to this site for the idea of using the Reminder event for an appointment, etc. and for using the fields of the appointment to populate the email data. Perhaps the edits/additions I have done will be helpful to those who want to append a signature to the email.

' Run when a reminder fires
Private Sub Application_Reminder(ByVal Item As Object)
Dim oMsg As MailItem
Set oMsg = Application.CreateItem(olMailItem)

' Only handle appointment reminders (may change later)
If Item.MessageClass "IPM.Appointment" Then
Exit Sub
End If
Dim oAppt As Outlook.AppointmentItem
Set oAppt = Item
' Only do for Category "Send Reminder Message"
If Not InStr(oAppt.Categories, "Send Reminder Message") >= 0 Then
Exit Sub
End If

oMsg.To = Item.Location
oMsg.Subject = Item.Subject
oMsg.Body = Item.Body
Dim sig As String
oMsg.HTMLBody = Item.Body & "" & sig ' oMsg.HTMLBody

' Try to specify sending account
Dim oAccount As Outlook.Account
For Each oAccount In Application.Session.Accounts
If oAccount.DisplayName = "alias@domains.com" Then
oMsg.SendUsingAccount = oAccount
Exit For
End If
Next
oMsg.Send
Set oMsg = Nothing
End Sub

Private Function ReadSignature(sigName As String) As String
Dim oFSO, oTextStream, oSig As Object
Dim appDataDir, sig, sigPath, fileName As String
sigPath = appDataDir & "" & sigName
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextStream = oFSO.OpenTextFile(sigPath)
' fix up relative path references to images in the sig file
fileName = Replace(sigName, ".htm", "") & "_files/"
sig = Replace(sig, fileName, appDataDir & "" & fileName)
End Function

29. Ben says

Hi Diane,

Tried the above code and it worked for the first day and stopped working after that. I've also changed the security level but it hasn't worked since. Here's my code:

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 <> "Test" Then
Exit Sub
End If

objMsg.To = "abc@hotmail.com"
objMsg.CC = "abc@hotmail.com"
objMsg.Subject = "Test"
objMsg.Body = "Testing Testing 1 2 3"
objMsg.Send

Set objMsg = Nothing
End Sub

• Diane Poremsky says

Try commenting out the the if... end if sections and see if it works. (Add a ' to the beginning of each line)

What is macro security set at?

30. Ben says

Hi Diane,

Tried that too.. Still doesn't work. Macro security is set at "No security checks for macros"

31. Ben says

Hi Diane,

I'm trying to send the email from a template. From what I understand from your other threads, I just need to edit the "Set objMsg" row. So the code should look like:

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 "Test" Then
Exit Sub
End If

objMsg.To = "Doe, John"
objMsg.CC = "Doe, John"
objMsg.Subject = "Template"
objMsg.Send

Set objMsg = ("C:\templates\template.oft")
End Sub

Is this correct?

• Diane Poremsky says

No, not quite correct. This line: Set objMsg = Application.CreateItem(olMailItem) needs changed. It should be Set objMsg = Application.CreateItemFromTemplate("C:\path\to\test-rule.oft"). The last Ste objMsg is set objmsg = nothing.

32. john says

Hi Diane,
I have attempted to run the code for "Send a message to someone when a reminder fires"
1. The person I need to remind when an appointment reminder fires is me.
2. If I use an email address that is outside our exchange network... menaing i have to type in an email address such as a hotmail , and or live account it works fine.
3. If I am just using my internal email address that is in the GAL. then it gives me an error: "Outlook does not Recognize One or More Names" and highlights the objMsg.Send. Im not sure what is happening as does this only work with typed in email addresses? when I type in my corporate email address it reverts to my named refered in the GAL. I hope this makes sense, thanks

• Diane Poremsky says

It should work with the exchange address. What are you entering as the internal address? Try use your alias or your smtp address. Using your name as it appears in the GAL should work too ("John D. Smith") - if outlook can't resolve the address, it should work.

33. Matthew Wied says

Hi Diane,
The code work but will not send the email it only goes to the outbox. How can I fix that?
Here is the code I am using:
Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem
Set objMsg = Application.CreateItemFromTemplate("C:\Users\MCWIED\Documents\Cal.oft")

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

• Diane Poremsky says

It should be sent on your next scheduled send or immediately, if that is your setting. Do you get any send and receive error messages? if you have the outbox open and are watching the mail drop into it, try switching to another folder - you may have an addin that marks mail read.

34. Karen says

Hi Diane,
This is exactly what I need for some bills. We have a billing agreement in place and I need to send a reminder every 2 weeks at 10:00 to the business to have them process the agreement. I also need to copy our accounts email in on this as well.

1) Do I copy & paste this new code (send email on reminder) under the Auto BCC code?
2) What is the string to include a CC/To for the other email? (process@company & accounts@company)

It's not a meeting so I don't want to use the "attendees" function, it's just an email to process a payment.

Lastly, when this triggers will the Auto BCC also trigger? (I want this in case of dispute of email being sent).

Karen

• Diane Poremsky says

Yes, paste it under the autobcc macro - both will run, the reminder fires, a mail is sent and the autobcc one picks it up on send.

This is the to field:
objMsg.To = Item.Location
use semicolon separators when you enter multiple addresses in the location field

if you need to use the CC field too, we need to find another field that isn't used. WE can't use the CC field (optional attendee) unless we send it.

If this is the only thing you'll use it for, you could either hardcode the fields in the macro, using objMsg.CC = "email@address.com", or change it do it pulls up a template that is addressed.

35. Karen says

Genius! Thank you Diane.
This is my finished code :) A little bit of everything in here :D I'm thrilled I managed to piece it together and it works.

-----
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 "Bus - ACCs FK" Then
Exit Sub
End If

objMsg.To = Item.Location
objMsg.Subject = Format(Now, "YYYYMMDD - HH:mm:ss") & " | " & Item.Subject
objMsg.Body = Item.Body
objMsg.BCC = "deviceemail@mydevice"
objMsg.Send

Set objMsg = Nothing
End Sub
-----

I don't check my regular BCC addresses on my phone so I need to hardcode my phone email so I can check it when I'm out at an appointment so I know that this email goes through. It's a time sensitive one so I need to make sure I have the date in the subject (or body, i'm going to try both :D) so the receiver knows it's a new reminder.

Using multiple categories for things isn't a problem, i'll just keep creating categories as my variable emails are required. In this case the receiver, the CC & BCC will never change so it will have it's own category.

Thank you :D

36. Karen says

Hi Diane,
Sorry to bug you :) I've learnt a lot the last few days and your site has helped me tremendously.

I now want to expand my code a little further.
I'm trying to automate this new email schedule as much as possible, with a set & forget ideal.

-> Appointment Reminder triggers email
-> Email is sent (with attachment, coded)
-> Email is saved to HDD folder
-> EMail (sent) is moved from the Outlook Sent Box to Accounts/Sent Outlook folder

I've managed to get the email to send as HTML (excluding the inserted time), and I've been able to attach 1 file (I haven't tried to include 2), so now I need to file & tidy my sent box & HD emails. :)

So, these are my 2 questions:

1) I have managed to get HTML to work in the email:
objMsg.HTMLBody = Format(Now, "Long Date") & Item.Body
The HTML is edited in my appointment screen & it works great.

I can not however work out how to also get the automated time to become HTML. I have tried all sorts of variations in the VB code.
eg: objMsg.HTMLBody = Format(Now, "Long Date") & Item.Body
However nothing seems to work to get the date to be in the HTML format, it throws a syntax error no matter how it's coded.

2) Also, I'd like to be able to save the email to my HD (specifically my backup folder that syncs to dropbox & box), nothing fancy in the saveas title, just the email as it is: Subject = Format(Now, "YYYYMMDD - HH:mm:ss") & " | " & Item.Subject
so it would be: 20131208 - 0054 | Accounts Reminder.msg
folder: e:/blah/blah/accounts/company/notices/.msg

I know I can do a bulk saveas using VBA (which I'd need to look into to schedule it monthly), but I'd like to be able to do it at the time the email sends.

2.b) Can I add to this script a move to folder (outlook) at the end of the "generate new mail" script? re: -> EMail (sent) is moved from the Outlook Sent Box to Accounts/Sent Outlook folder

Thank you for help & support in advance.

Karen

• Diane Poremsky says

I'll have to check on the date stuff, but saving to the hard drive and deleting from the sent folder should be fairly easy, just need to tweak the code samples I have elsewhere on the site to work with the specific message after its sent.

37. Emily Jackson says

Hi,

Many thanks for this. I was hoping somebody would be able to help me with categories, I want to be specific about what I send to who so I've created separate categories. I was just wondering how to incorporate this into the code? What I need to ask the code to do is: if it is for category A send an email, if it's for category B send an email. I'm getting very confused with IF statements!

Thanks :D

• Diane Poremsky says

if you have a lot of categories to check, you'll either need to use a case statement or send the email for everything and use a specific category, or multiple categories when you don't want the macro to run.

For example, if you want to always send except when the category is no, use this
If Item.Categories = "No" Then
Exit Sub
End If

Categories are a string, so using Send message and Mary categories will cause this to fail as outlook will see it as "Send Message, Mary" - you'd need to use instr("send message") to use it.
If Item.Categories <> "Send Message" Then
Exit Sub
End If

38. Emily Jackson says

Hi Diane,

Sorry, I'm really struggling with this. I've spent a few days playing around but can't get it to do what I want.

For an examples sake say that I have 2 categories:

Category A - reminder to send to cata@example.co.uk
Category B - reminder to send to catb@example.co.uk

I can only ever get Category A to send. I've tried a few different ways but it keeps failing, I would be very grateful for any help.

Thanks,
Emily :D

• Diane Poremsky says

It will probably be easier to use = rather than not equal... also, the category names are case-sensitive as written.

try this
If Item.Categories = "CatA" Then
objMsg.To = "cata@example.co.uk"
ElseIf Item.Categories = "Catb" Then
objMsg.To = "catb@example.co.uk"
Else
exit sub
End If

39. Emily Jackson says

It works perfectly! Thank you for your help. :)

40. Felix Figueroa says

Diane, I used the Send a message to someone when a reminder fires code and copied it in and it fires as expected, problem is I get a runtime error Outlook does not recognize one or more name. When I debug, it points to the objMsg.Send line. Any clues?

• Diane Poremsky says

is the address you are putting in the To line valid?

41. juzar para says

hi,

Can you help me with code that trigger email if I have not sent email to particular address before particular time..... thanks in advance

• Diane Poremsky says

You'd need to scan the sent folder for a message sent to an address, then send the message. I'd probably trigger it with a reminder macro.

42. Felix Figueroa says

ReRead description and was able to see what I was doing wrong. Code works great. Thanks so much Diane.

43. Greg says

Hi, I'm missing something, I added the code you developed into the ThisOutlookSession. Then you keep mentioning macro's. Do I copy this same code and place it in a macro or reference it? I haven't done anything like this before and it looks like exactly what I need. Any further instructions would be appreciated.

Thanks

• Diane Poremsky says

The code is the macro. Just paste it into ThisOutlookSession and create something with a reminder that will fire as soon as it's saved to test. If you change .Send to .Display, the message will open so you can see if it looks like you want it to look.

44. Mike says

Hi Diane,
Thanks for the great information. I'm new to this and I'm trying to implement the "Select an appointment and send a message" code and have two questions. Is the code you have in this step all that is needed. The text reads "With a few tweaks, the macro above can be used to send a message by selecting the appointment then running the macro." Does that mean you need the previous text and what you have listed in that section?

Additionally, I don't really understand the step: "Get the GetCurrentItem function from..." I followed the link and tried a couple things but it kept resulting in compile errors so I'm missing something. Ideally this would work if I ran the macro with the appointment opened or if I have it selected.

45. Mike says

Hi Diane,

I'm trying to have a reminder email only for appointments that I run the macro on manually. I tried working with "Select an appointment and send a message" but I don't understand the part pertaining to the GetCurrentItem function. Ideally I could run the macro whether I had an item open or if I had it selected in the calendar. If I had to choose between the two I wold prefer to select the appointment and run the macro. I followed the link and tried a couple options but I kept getting run-time errors. I'm new to VBA so I'm probably missing something.
The way I read it, do I paste the "Send a message to yourself when a reminder fires" in the ThisOutlookSession and then use the "Select an Appointment code in a module?

Thanks,

• Diane Poremsky says

If you only want to work with selected appointments, not open ones, replace "getcurrentitem()" with this - objApp.ActiveExplorer.Selection.Item(1)

Paste the macro into ThisOutlookSession - you only need one of the macro groups, in your case, the 'select an appointment' code. Then select an appointment and run the macro. You can create a QAT or ribbon button for the macro. Make sure macro security is set to low.

46. Emma says

Hi Diane,

This is working great for me apart from when I create recurring appointments, the reminder comes up but the email doesn't fire. Should it work?

Thanks,
Emma

• Diane Poremsky says

I'll have to test it. It should work since its based on the form name and recurring events don't use a different form name.

47. Mike says

Thanks for the reply and sorry for spamming you with the same question. That worked but I think I misunderstood what the macro was doing. I am trying to accomplish a combination of the Send a message to yourself and Send a message when a reminder fires. I want to receive an email notification for some items but not all. My thought is that I would select the appointment I need the reminder to occur on, run the macro and then receive the email when the reminder fires.

Thanks again!

• Diane Poremsky says

Ah. I may have misunderstood. If you want an email for specific reminders, assign a category to the appointment then use the first macro - change the category name as needed.
If Item.Categories <> "Send Message" Then
Exit Sub
End If

if you use multiple categories, you need to use if instr(item.categories, "category name") > 0 for the first line.

48. Eric says

I have more people I need to send the e-mail too then can fit in the location field. About 40 people in all. Any idea how to set this up? When I create a contact group, the macro errors out when it try's to send.

• Diane Poremsky says

Contact group should work. Outlook would pick up the name and insert it in the To field then resolve it on send. What is the error message?

49. Eric says

Run-time error'-2147467259 (80004005)':

Outlook does not recognize one or more of the names.

Current the group name is Test. I have (2) e-mails in the group and both are correct. In the location field, I have entered Test.

• Diane Poremsky says

I'm pretty sure its referring to the Test group, not the addresses in the group. Try resolving the address -
Dim objRecip As Recipient
Dim Recipients As Recipients
'Resolve each Recipient's name.
For Each objRecip In objMsg.Recipients
objRecip.Resolve
Next

if that doesn't work, post the code you are using and I'll test it.

50. Tomas Juzko says

Hello, I am using your script (the 1st on), and it works great.
But I need additional function - to send a link with that e-mail.
I've used:
ObjMsg.Body = strLink & " " & " This e-mail was generated automatically"
But it sends the link as a plain text only. Do you have any advice for me?
Thank you

51. Tomas Juzko says

Hello,
I solved it by this:
ObjMsg.HTMLBody = "" & _
"My Excel" & _
"This email was generated automatically" & ""

52. Samantha Walz says

Hi Diane,
I am brand new to this and most of it is over my head. I have tried a few of the codes but not having much luck because i don't know what to fill in where in the code. I successfully used the "send reminder to yourself" code but put my coworkers email in instead of mine.

Here is what i'm trying to do. I have a shared calendar for myself and 2 coworkers. I am the only one that receives reminders, so i was hoping to add the code so that when i receive the reminder they get an email about it. I want this to only happen when reminder is for the calendar "Pharmacy Schedule" and not for my personal email calendar. I this possible?
Can you please help by pasting code here and showing me where to put their emails: ie coworker1@email.com and coworker2@email.com. and Pharmacy Schedule. Thanks in advance!

• Diane Poremsky says

objMsg.To = "alias@domain.com;alias@domain2.com"

the easiest way to handle the calendar (assuming a modern version of outlook that fires reminders from any folder) is to set a color category that is unique to the events and look for that, rather than looking for a folder.

something like this:
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 Instr(Item.Categories, "Pharmacy Schedule Reminders") Then

objMsg.To = "alias@domain.com;alias@domain2.com"
objMsg.Subject = Item.Subject
objMsg.Body = Item.Body
objMsg.Send

End If

Set objMsg = Nothing
End Sub

53. Samantha Walz says

Thank you Diane! It's working! This solved a big problem for me, greatly appreciated!

54. Wee Lee says

Hi Diane, i was wondering if the above code work if lets say i have alot appointment and i wish to send a reminder to attendee based on different appointment. Is it possible to do that?

Thanks!

• Diane Poremsky says

You can control which reminders trigger messages using categories. I don't have any samples that grab an address from a meeting or appointment, but it is possible to grab an address and send that person a reminder.

55. mattblak81 says

Hi Diane,

I have no problem getting this working but unfortunately when it does fire it just keeps spilling out messages until I turn the reminders to none or delete/dismiss the message.

Looks good but at the minute too effective :)

Thanks for your time, you must be irritated by supporting this a couple of years after you posted it!

Cheers,

Matt

• Diane Poremsky says

It will fire when you restart outlook if you didn't dismiss the reminder. If you don't want to dismiss the reminder, and are using the version that sets a category, change the category at the end:
Item.Categories = "Message Sent"
Item.save
If not using categories, do so. :)

The reminders shouldn't just keep firing over and over while outlook is open. Try restarting Outlook using the /cleanreminders switch and see if it helps.

56. mattblak81 says

Thanks Dianne, So something like this?

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 <> "Appraisal Reminders" Then
Exit Sub
End If

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

Set objMsg = Nothing

Item.Categories = "Message Sent"
Item.Save

End Sub

• Diane Poremsky says

Yes, that should work (assuming the symbols wordpress removed and I added to your example were <>).

57. veronica says

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

It works well for me.. but I would like to have additional cc field.. how can this be done?

• Diane Poremsky says

Put all of the addresses in the location field and split it - this code assumes two addresses, but if you need more, use an unusual character, like ] as the separator between the to and cc names and replace the ; in the code.

Dim semi As Long

semi = InStr(1, Item.Location, ";")
Debug.Print semi

Debug.Print Left(Item.Location, semi)
Debug.Print Right(Item.Location, Len(Item.Location) - semi)

objMsg.To = Left(Item.Location, semi)
objMsg.CC = Right(Item.Location, Len(Item.Location) - semi)

• Diane Poremsky says

Here is a second way to split it in two - i separate the to and cc addresses with a | - semicolon between addresses if using multiple addresses in either field.

Dim strLocation As String
strLocation = Item.Location

58. DIck Fotoples says

I entered your code as suggested, but the macro does not show up under Macros under the developer tab. Is it supposed to? Except for the category, how does it know?

• Diane Poremsky says

It won't be listed with the macros because its automatic - you can't run it manually and only macros you'd run manually show up there.

59. Brian says

Thanks for the hints. For some reason, I cannot get the email function to work. I have done a bit of testing, and cant figure out what I have wrong. I have macro security set to "No Security Check". I have commented out the MessageClass check and Categories check. I even added a MsgBox test at Logon (which works).
I am using Outlook 2007. Is that the issue?
----------------------------------------------------------------------------------------------
Private Sub Application_MAPILogonComplete()
MsgBox "TestMe"
End Sub
----------------------------------------------------------------------------------------------
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.To = "XXXX@yahoo.com"
objMsg.Subject = Item.Subject
objMsg.Body = Item.Body
objMsg.Send
Set objMsg = Nothing
End Sub
----------------------------------------------------------------------------------------------

• Diane Poremsky says

it works here in outlook 2007 - every reminder = a new message. (i changed send to display so it opened on the screen instead of spamming a mailbox with test messages). I can't think what could be wrong.

60. Devi says

Hi Diane:

I am trying to set up an email remainder for my outlook calendar event. I can understand the code that you have given. The question I have is, I have a separate calendar which has all required calendar events plugged into it and I want to use the code just for that specific calendar and not for the other couple of calendars(my day to day calendar as well as my boss calendar) that I use for my daily office work. I hope I am making myself clear on this.

61. Delwyn says

Hi Diane,
I am using your "Pop up a dialog" code. It appears that you only see the message pop in you are in Outlook. Can it be set to pop over any application you are in? Thanks

• Diane Poremsky says

I think you's need to call a Windows message box, not outlook.

62. Michael says

Hi Diane

You are an AMAZING resource! Thank you so much for posting this info. It's opened my eyes to what is possible in Outlook.

I'm hoping you can help me tweak this. I set up a shared calendar for my department. I entered your macro. Works BEAUTIFULLY....except -- it also sends out emails for reminders generated by my own personal default calendar. So...my department is now completely up to date on what I do after hours :-(

Any ideas on how to restrict this to just the shared calendar?

Thanks again!

• Diane Poremsky says

The quick fix is to set a category (in this example, called Send Message) on the appointments on the shared calendar and add this at the top of the macro -
If Item.Categories <> "Send Message" Then
Exit Sub
End If

it can go right after the macro name. if you use categories on the events, replace the if line with
If instr(1,item.categories, "Send Message") > 0 Then
so it looks for the category name in the string of categories. The category name is case sensitive.

The more complicated way is to see where the parent appointment originated. I don't have code for that though.

• Michael says

Oh wow...you're a gem!!!!

Worked like a charm.

Thank you so much for the great help, and the speedy response!!

63. bilbobird says

Your code for "Send a message to someone when a reminder fires" has worked marvelously for a weekly email. Can you help me add one thing? I would like to specify a reply email address, which I can normally do in the options of a new message. I'm using Outlook 2010, Windows 7.

Thanks!

• Diane Poremsky says

As far as i know you can't set the reply to address. You can set a From address and replies will go to that address.

64. Monika says

Hi Diane,

This is workin perfectly, thank you.
Only one problem I have been trying to sent the email with attachment and the system is sending the email but no attached file.

Kind Regards,
Monika

• Diane Poremsky says

If you have an attachment, you need to use a macro to attach it, you can't just copy the attachment. Use the CopyAttachments script at http://www.slipstick.com/outlook/email/reply-replyall-attachments/ if the attachment is in the appointment form. If you can use the file path to the attachment in the location field (instead of the email address) you'll just need to use attachment add.

65. Karen A says

Hi Diane,

I've used your "Send Email when Reminder Fires" code and it's worked like a charm. The only thing i want to do, however, is make all the recipients BCC since my email will be sent to a bunch of different companies as a reminder for required information every month.

How would I be able to do this on your code?

'Original function written by Diane Poremsky: http://www.slipstick.com/developer/send-email-outlook-reminders-fires/
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 "Automated Email Sender" Then
Exit Sub
End If

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

Set objMsg = Nothing

End Sub

• Karen A says

hello!?!?

• Diane Poremsky says

Sorry about missing the earlier message - I sometimes get behind in my replies. :)

• Diane Poremsky says

This line:
objMsg.To = Item.Location

can be changed to
objMsg.BCC = Item.Location

• Karen A says

Thanks Diane. You're amazing! I'll give it a try!

Hi Diane

Would it be possible to have this only run on Tasks (and not appointments) ? or perhaps even better, is it possible to have two different macros, one for Tasks and one for Appointments ? Just trying to use it for personaly management and currently have both appointments and tasks firing complicates things slightly !

Regards

• Diane Poremsky says

you can filter on item type or use categories to filter the items out or control the actions.

If Item.MessageClass = "IPM.Appointment" Then
'do this code
End If

If Item.Categories = "Send Message" Then
'do this code
End If

Hi Diane

I've tried filtering based on IPM.Appointment and IPM. Task however I keep getting a "Block if without end if" error on the end sub. I'm not really sure where the error in my code is.

I've posted the code below, if you could point me in the right direction I would really appreciate it !

Private Sub Application_Reminder(ByVal Item As Object)

Dim objMsg As MailItem

Set objMsg = Application.CreateItem(olMailItem)

objMsg.Subject = "Task: " & Item.Subject

' Code to handle the 4 types of items that can generate reminders
Select Case Item.Class
objMsg.Body = _
"Start: " & Item.StartDate & vbCrLf & _
"End: " & Item.DueDate & vbCrLf & _
"Details: " & vbCrLf & Item.Body
End Select

End If

If Item.MessageClass = "IPM.Appointment" Then
Set objMsg = Application.CreateItem(olMailItem)

If Item.MessageClass = "IPM.Appointment" Then
objMsg.Subject = "Appointment: " & 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
End Select

End If

objMsg.Send
Set objMsg = Nothing
End Sub

67. Eric says

Hi Diane,

I am back trying to fix an issue with using a e-mail group and the automatic send.

Here is the current code I am trying to use:

'Original function written by Diane Poremsky: http://www.slipstick.com/developer/send-email-outlook-reminders-fires/
Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
Dim objRecip As Recipient
Dim Recipients As Recipients

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

If Item.Categories "Automated Email Sender" Then
Exit Sub

'Resolve each Recipient's name.
For Each objRecip In objMsg.Recipients
objRecip.Resolve
Next

End If

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

Set objMsg = Nothing
End Sub

If you have any recommendations, please let me know.

Finally, in the location field, I have the group name test.

• Diane Poremsky says

So the contact group name isn't resolving? Do you get any error messages when it tries to send? It *should* autoresolve on it's own as long as the group contact exists in the address book - the .resolve command just speeds it up.

68. Jason says

This is awesome! Thank you for putting this together.

69. Dali says

hey guys

you might have an idea how to solve this issue, reading through your entries :)

i want to send out autmoated mails with voting polls! unfortunately the appointment functions dont have the voting incorporated which makes the initial futile for my purpose. However, maybe there is a way around it? i was thinking to have a reoccuring reminder set for myself and this should trigger the sending of a vote mail (always the same content) that has been saved in a specific folder. is this feasible?

just for better understanding:
the aim is to send this voting poll on e.g. monday to find out who has time for a reoccuring certain activity.

thx for any help

kr
dali

Please post long or more complicated questions at OutlookForums by Slipstick.com.

If the Post Comment button disappears, press your Tab key.