I’m often asked how to be reminded if a message does not arrive within a specified time. This a popular request by administrators and others who receive routine status messages. When a status message doesn't arrive, it can mean there is a problem.
Is it possible to set a reminder, or email myself automatically, if a particular email does not arrive by a certain time every hour?
Yes, you can do this using a run a script rule. Outlook doesn't have a timer, so you'll need to use reminders to trigger the check. When a message arrives, a reminder is set for one hour and the reminder and flag are removed from the older message(s). If you prefer, you can delete the older message instead.
While this code sample only triggers a reminder, you can use the method described at Send an email when an Appointment reminder fires to send an email when the reminder fires.
To use, add this code to a new module in Outlook's VBA Editor and create a run a script rule.
Sub RemindNewMessages(Item As Outlook.MailItem) Dim objInbox As Outlook.MAPIFolder Dim intCount As Integer Dim objVariant As Variant Set objInbox = Session.GetDefaultFolder(olFolderInbox) ' if the message is in another mailbox, use the data file name in the folders list ' should be the email address ' Set objInbox = Session.Folders("name in folder list").Folders("Inbox") ' Set the flag/reminder on newly arrived message With Item .MarkAsTask olMarkThisWeek .TaskDueDate = Now + 1 .ReminderSet = True ' Reminder in one hour .ReminderTime = Now + 0.041 .Categories = "Remind in 1 Hour" .Save End With Item.Save ' look for existing messages and remove the flag and reminder For intCount = objInbox.Items.Count To 1 Step -1 Set objVariant = objInbox.Items.Item(intCount) If objVariant.MessageClass = "IPM.Note" Then If LCase(objVariant.Subject) = LCase(Item.Subject) And objVariant.SentOn < Item.SentOn Then ' clear flag and category With objVariant .ClearTaskFlag .Categories = "" .Save End With 'or just delete the older messages ' objVariant.Delete Else End If End If Next Set objInbox = Nothing End Sub
Use an ItemAdd macro to watch a shared mailbox
This version of the macro uses an ItemAdd macro to watch the inbox in a shared mailbox. The shared mailbox needs to be in your profile for this to work.
It checks every message that arrives, you'll need to use an If statement if you want to check only certain messages.
Option Explicit Private objNS As Outlook.NameSpace Private WithEvents objNewMailItems As Outlook.Items Private objInbox As Outlook.MAPIFolder Private Sub Application_Startup() Dim objOwner As Outlook.Recipient Set objNS = Application.GetNamespace("MAPI") Set objOwner = objNS.CreateRecipient("chris") objOwner.Resolve If objOwner.Resolved Then Set objInbox = objNS.GetSharedDefaultFolder(objOwner, olFolderInbox) End If Set objNewMailItems = objInbox.Items End Sub Sub objNewMailItems_ItemAdd(ByVal Item As Object) Dim intCount As Integer Dim objVariant As Variant ' Set the flag/reminder on newly arrived message With Item .MarkAsTask olMarkThisWeek ' .TaskDueDate = Now + 1 .ReminderSet = True ' Reminder in one hour .ReminderTime = Now + 0.041 .Categories = "Remind in 1 Hour" .Save End With Item.Save ' look for existing messages and remove the flag and reminder For intCount = objInbox.Items.Count To 1 Step -1 Set objVariant = objInbox.Items.Item(intCount) If objVariant.MessageClass = "IPM.Note" Then If LCase(objVariant.Subject) = LCase(Item.Subject) And objVariant.SentOn < Item.SentOn Then ' clear flag and category With objVariant .ClearTaskFlag .Categories = "" .Save End With 'or just delete the older messages ' objVariant.Delete Else End If End If Next End Sub
How to use macros
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor
More Information
More Run a Script Samples:
- Autoaccept a Meeting Request using Rules
- Automatically Add a Category to Accepted Meetings
- Blocking Mail From New Top-Level Domains
- Convert RTF Messages to Plain Text Format
- Create a rule to delete mail after a number of days
- Create a Task from an Email using a Rule
- Create an Outlook Appointment from a Message
- Create Appointment From Email Automatically
- Delegates, Meeting Requests, and Rules
- Delete attachments from messages
- Forward meeting details to another address
- How to Change the Font used for Outlook's RSS Feeds
- How to Process Mail After Business Hours
- Keep Canceled Meetings on Outlook's Calendar
- Macro to Print Outlook email attachments as they arrive
- Move messages CC'd to an address
- Open All Hyperlinks in an Outlook Email Message
- Outlook AutoReplies: One Script, Many Responses
- Outlook's Rules and Alerts: Run a Script
- Process messages received on a day of the week
- Read Outlook Messages using Plain Text
- Receive a Reminder When a Message Doesn't Arrive?
- Run a script rule: Autoreply using a template
- Run a script rule: Reply to a message
- Run a Script Rule: Send a New Message when a Message Arrives
- Run Rules Now using a Macro
- Run-a-Script Rules Missing in Outlook
- Save all incoming messages to the hard drive
- Save and Rename Outlook Email Attachments
- Save Attachments to the Hard Drive
- Save Outlook Email as a PDF
- Sort messages by Sender domain
- Talking Reminders
- To create a rule with wildcards
- Use a Macro to Copy Data in an Email to Excel
- Use a Rule to delete older messages as new ones arrive
- Use a run a script rule to mark messages read
- Use VBA to move messages with attachments
I just use the method u provided plus some modifications and solved my problem faces at work, big thanks to u, I have long been not using VBA and required to do it on my new job. Appreciate!
Hi Diane, I have attempted to run this script in Outlook 365 however it doesn't seem to apply the reminder. Is the macro likely to also work in Outlook 365 or will it need amending? Thanks in advance!
It will work in all of the Windows desktop versions of Outlook.
Which macro are you using?
The first macro listed above (for a non-shared mailbox) - I have simply copy and pasted exactly as above although I have amended the 1 hour to 15 minutes. I have also ensured to enable all macros in the trust center. I don't get any errors when the macro is run so suggestion is it's working however no reminder is set??
Hi Diane. I am also an administrator and I ran into the same issue regarding having to read multiple alert e-mails daily. It's mostly to find the failed backups between all the successful backups and then worrying if an e-mail is even delivered. Since I am useless at coding I had a developer build me a tool called http://www.smtpviewer.com which worked so nicely I decided to roll it out to the general public. I hope as an alternative you readers can find value out of my site.Regards
This is a great script, thanks for sharing.
I have been running this script in Outlook 2016, Online Mode Exchange 2010.
I have noticed once I moved myself to Exchange 2016 from Exchange 2010, the script no longer worked. Have you seen this before?
Thanks,
Joe
all of the macros are tested in Outlook 2016 against Exchange online... so no, i haven't seen it. Usual cause of failure is macro security (change not likely if you just changed email accounts). The actual account is not hardcoded into it, so it should work with any server.
Hello Diane, Thank you for sharing this, it will be most helpful. I have one question related to it, I would like to have the script look for the messages in a specific folder and remove the reminder flag only from others in that same folder. I am setting up the rule to first move specific messages to that folder and then run the script against them. Tried some other settings to this, although I could not get it to work
Set objInbox = Session.GetDefaultFolder(olFolderInbox)
I would appreciate your input on this.
Best regards,
Stephen
Exactly fitting, but I have an additionally inbox which I share with other colleagues. How can I implement this rule anyway?
In the Outlook Web App I didn't see that I can add a script. Is it possible with the Outlook client? If so, have the client always to be run?
You would need to run it in outlook - but as long as the mailbox is open in your outlook profile, you can watch the folder. You'd need to convert the macro to an itemadd macro and watch the shared folder if the account is not open in your mailbox as a separate account.
I added a macro that watches a shared mailbox to the end of the article.
Thank you, is working now.
Hi Diane,
I tried your solution in my office. We work white outlook 2013 and a Exchange server. I have a error whit this part ".TaskDueDate = Now + 1".
A pop-up appears whit this msg "this object does not support this method".
Can you have a solution ?
Thank you very much.
Assuming you are not using IMAP, does it work if you change Now + 1 to Now + 2 (or higher) or use Date + 2?
or change markastask to .MarkAsTask olMarkTomorrow
(Due tomorrow doesn't work with olmarkthisweek if you are early in the week)