• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Running Outlook Macros on a Schedule

Slipstick Systems

› Developer › Code Samples › Running Outlook Macros on a Schedule

Last reviewed on August 25, 2016     23 Comments

How do I run a macro 5 minutes after Outlook starts?

Outlook doesn't have a timer function but you can use Appointment or Task Reminders to trigger macros. Set up an Application_Reminder macro that will do something when a reminder fires. To limit it to running when specific reminders fire, use an If statement to look for words in the subject or a specific category.

If you want the macro to fire a specified time after you restart Outlook, use an Application_Startup macro to create the appointment.

Create an appointment reminder to trigger a macro

If you need to rerun the process kicked off by the reminder, run CreateAppointment macro from the VBA editor at any time.

Other "reminder macros" are at "Open a Webpage when a Task Reminder Fires" and "Send an Email When a Reminder Fires"

' The Private subs go in ThisOutlookSession
Private WithEvents olRemind As Outlook.Reminders

Private Sub Application_Startup()
  CreateAppointment
End Sub

Private Sub Application_Reminder(ByVal Item As Object)
Set olRemind = Outlook.Reminders

If Item.MessageClass <> "IPM.Appointment" Then
  Exit Sub
End If
 
If Item.Categories <> "Run in 5" Then
  Exit Sub
End If
 
' Call your macro here
MsgBox "It works!"

'Delete Appt from calendar when finished
Item.Delete

' Create another appt to repeat the process
CreateAppointment

End Sub

' dismiss reminder 
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)

    For Each objRem In olRemind
            If objRem.Caption = "This Appointment reminder fires in 5" Then
                If objRem.IsVisible Then
                    objRem.Dismiss
                    Cancel = True
                End If
                Exit For
            End If
        Next objRem
End Sub

' Put this macro in a Module
Public Sub CreateAppointment()
Dim objAppointment As Outlook.AppointmentItem
Dim tDate As Date
' Using a 1 min reminder so 6  = reminder fires at 5 min. 
tDate = Now() + 6 / 1440

Set objAppointment = Application.CreateItem(olAppointmentItem)
      With objAppointment
        .Categories = "Run in 5"
        .Body = "This Appointment reminder fires in 5"
        .Start = tDate
        .End = tDate 
        .Subject = "This Appointment reminder fires in 5"
        .ReminderSet = True
        .ReminderMinutesBeforeStart = 1
        .Save
      End With
End Sub

How to use the macro

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. If Outlook tells you it needs to be restarted, close and reopen Outlook. Note: after you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Now open the VBA Editor by pressing Alt+F11 on your keyboard.

To use the macro code in ThisOutlookSession:

  1. Expand Project1 and double click on ThisOutlookSession.
  2. Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)

Application_Startup macros run when Outlook starts. If you are using an Application_Startup macro you can test the macro without restarting Outlook by clicking in the first line of the Application_Startup macro then clicking the Run button on the toolbar or pressing F8.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More information as well as screenshots are at How to use the VBA Editor

Running Outlook Macros on a Schedule was last modified: August 25th, 2016 by Diane Poremsky
Post Views: 26

Related Posts:

  • Reset reminders closer to Meeting time
  • Use a macro to create a rule to move messages
  • Scheduling Drafts in Outlook
  • Send an Email When a Reminder Fires

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Comments

  1. Adauto Araujo says

    March 21, 2024 at 10:23 am

    Wonderfull! Thanks. The only addition I'll do, is to change from this: tDate = Now() + 6 / 1440 to this: tDate = Now() + TimeValue("00:05:00"). I think it's more readable and easier to edit.

    Reply
  2. J.A. Clark says

    May 24, 2022 at 3:50 pm

    After copy/paste all code as instructed in tutorial and then closing both VBA Editor and Outlook to restart, an error is displayed, 'Compile error: Invalid attribute in Sub or Function'. The first line of cod is highlighted in 'This OutlookSession'.

    Running Outlook Office 365 v2202.

    Any assistance would be appreciated.

    Reply
    • Diane Poremsky says

      June 9, 2022 at 4:41 pm

      This line is highlighted?
      Private WithEvents olRemind As Outlook.Reminders

      If it's ' The Private subs go in ThisOutlookSession - go ahead and delete it.

      Reply
  3. Krishna says

    January 5, 2021 at 1:55 pm

    Hi Diane,

    Just adding a little comparison info -

    I'm looking to run the code like how automatic replies are working. We will receive automatic replies, though the outlook-off. Like this, can VB Macros can work, if Outlook-Off/Close ?

    Thanks,
    Krishna

    Reply
  4. Krishna says

    January 5, 2021 at 1:49 pm

    Hi Diane,

    Hope all good and HNY ..

    We have done some coding in VBA on outlook, our requirement is to run the code over night - But we are not sure, outlook will opened or system is on .. Is there any possibility to make the macros execute at Outlook -Off time.

    Any suggestions will be great help.

    Many Thanks,
    Krishna

    Reply
  5. Prabhat Dewali says

    March 4, 2020 at 7:21 pm

    Hello Mam,
    Thanks for sharing this blog with us I am a beginner in VBA coding. Can you help me with how can I replicate the same appoint or "Create another appt to repeat the process" for the next day or till a certain day in the above code?

    "' Create another "Run in 5" appt to repeat the process
    "CreateAppointment "

    Reply
    • Prabhat Dewali says

      March 5, 2020 at 6:59 pm

      Thanks, I found the solution and now my question is solved it can be done from front end by using the recurrence option.

      Reply
      • Diane Poremsky says

        March 5, 2020 at 8:59 pm

        Yeah, using a recurrence is generally better than recreating a new one every day using a macro.

  6. Harrison Griffiths says

    February 12, 2020 at 7:07 pm

    Hello,

    I'm looking to create either a reminder or send an email to the creator of an appointment when the appointment is done or even maybe 5 min after its done. The purpose is for employees who might be working out in the field alone we want them to have a reminder governed by their Outlook calendars to email a colleague or coordinator that they have left work and are safe. Like a Check-In reminder to let the team know they're good and heading home.

    Thanks!

    Reply
    • Diane Poremsky says

      March 5, 2020 at 9:05 pm

      I don't think you'd want that automated - based on the appointment as it would generate the message, whether they were safe or not, just based on the meeting end time. They could use a macro to quickly generate a message and set it - no typing required.
      https://www.slipstick.com/developer/create-a-new-message-using-vba/

      Reply
  7. Ranjan says

    April 8, 2019 at 10:34 am

    Hi,
    I am looking for a code to create new outlook meeting invite.
    I have data in my excel like this.
    A-Name
    B-ID
    C-Recipient 1
    D-Recipient 2
    E-Subject
    F-Body
    I am aiming to achieve below. Could you please assist me here.
    1. Create a new meeting invite
    2. Add the above in right place
    3.check for the availability in calendar and set the meeting start and end date(duration is 1hour)
    4.Attach required files
    5. display/send

    Reply
    • Diane Poremsky says

      April 8, 2019 at 11:56 pm

      I have a macro that should meet your needs at
      https://www.slipstick.com/developer/create-appointments-spreadsheet-data/#meeting

      Reply
  8. Edwin says

    May 24, 2018 at 11:19 am

    Hello Diane,

    thanks so much for sharing this excellent information with the world. It has been extremely helpful to me and I am grateful.

    Reply
  9. Derek says

    August 9, 2017 at 4:32 pm

    Hi Diane,

    This is a helpful article, thanks for sharing. I am wondering if I can create a VBA macro in Outlook that will:
    1. Each night at 9:00 pm, email me a snapshot of my calendar for the next day
    2. Each Sunday at 9:00 pm, also email me a snapshot of my calendar for the upcoming week (Mon-Sun).

    From this article it sounds like there is no way to set a schedule per se, but I could set a daily recurring background appointment to run, which could fire the macro.

    Is this possible, and what is the degree of difficulty? I have extensive Excel VBA knowledge including drafting/sending emails in Excel VBA, but not with VBA for Outlook.

    Thanks!
    Derek

    Reply
    • Diane Poremsky says

      August 16, 2017 at 11:24 pm

      I don't think i have any code samples that come close to getting the snapshot (as a text list or emailed calendar) but it is doable - you'll need to keep outlook open to run the script - it can be triggered by a task or appt reminder (i have samples for this) and depending on the code, you might be able to do it as a vbscript, which could run in Windows task manager.

      Reply
    • Diane Poremsky says

      August 17, 2017 at 12:13 am

      As an FYI, the macro at
      https://www.slipstick.com/developer/print-list-recurring-dates-vba/
      can do it, with a little tweaking. The result isn't pretty - just a simple list.

      I'll post a tweaked version to a new page either tonight or tomorrow.

      Reply
    • Diane Poremsky says

      August 17, 2017 at 9:25 pm

      Ok... there are two macros (pretty formatting or simple list) to choose from at
      https://www.slipstick.com/outlook/calendar/email-tomorrows-agenda/

      Reply
  10. ninad says

    April 7, 2017 at 9:07 am

    Hi Diana,
    I need to send attachment to multiple recipient automatically at particular time in day say 8 AM the excel file which i need to send will have multiple column and macro will segregate file against recipient name and send to concerned recipient.
    Is it possible to use your file to send such attachment.

    It will gr8 if u can help me.....Thanks in advance

    Reply
    • Diane Poremsky says

      April 10, 2017 at 12:00 am

      You'll need a lot more code than just this macro but it would be possible. Code for the messages is here - https://www.slipstick.com/outlook/send-email-addresses-excel-workbook/

      Reply
  11. Ed B. says

    February 13, 2017 at 6:33 pm

    Thanks! Works great. Very slick solution. One question, is there a way to hide the appointment?

    Reply
    • Diane Poremsky says

      February 13, 2017 at 11:44 pm

      Well, you could create a view to hide the category assigned to the appointment and you could delete it via macro as soon as it fires.

      Reply
  12. Dan says

    September 17, 2016 at 10:13 pm

    Dear Diana,
    This code worked very well. One piece of advice though I need: how can I execute the created appointments deleted upon Outlook exit? I tried the code as follows:
    Private Sub Application_Quit()
    If Item.Categories = "Run in 5" Then
    Item.Delete
    End Sub
    But it did not work. Can you please advise what might be the proper code for it?

    Reply
    • Diane Poremsky says

      September 17, 2016 at 10:28 pm

      You need to find the appointments first, then delete them, or remove the category.
      short version is:
      sFilter = "[Categories] = " & Chr(34) & "Run in 5" & Chr(34)
      ' Apply the filter to the collection
      Set ResItems = CalItems.Restrict(sFilter)

      full example of the filter in use is at https://www.slipstick.com/developer/copy-recurring-appointments-meetings-series/

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 31 Issue 3

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Error Opening iCloud Appointments in Classic Outlook
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Error Opening iCloud Appointments in Classic Outlook

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2026 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.