How to create subscript for Outlook if an email comes in at certain time RRS feed

  • Question

  • Hi all. My experience (light) with VBA has been mostly Excel-based. I am trying to figure out how to make a subscript where if an email comes in between 2-3pm it raises in alert window, otherwise if the email does not come in, it raises alert window in all caps/bold and/or it sends an email to group in Red Text all caps that the email was no received.
    Wednesday, June 6, 2018 4:41 PM

All replies

  • Hello Blitzinger,

    You could create a rule to run a script while receiving a mail. In the script, you could try to check if the current time between 2-3 Pm and then msgbox  a alert windows.

    Here is the script to check the mail receive time.

    Sub CheckMailReceiveTime(mail As MailItem)
    objReceiveTime = mail.ReceivedTime
    If objReceiveTime >= 14 And objReceiveTime <= 15 Then
    MsgBox "The mail is received"
    End If
    End Sub

    Check below link to know how to create a rule to run a script.

    [Outlook] Add rule : Run a script

    If you are using Office 2016 and do not see a "Run a script" option, please refer to below link to re-enable it.

     The option to "Run a Scritp" has disappeared from the Outlook rules

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, June 7, 2018 7:59 AM