Monitor for mail NOT in the inbox

Posted on 2009-02-11
Last Modified: 2012-05-06
I have a requirement to monitor for email that should arrive at a certain time then be re-distributed to distribution lists. The goal is to monitor and if the mail hasnt arrived by a certain time then an alert is sent to cell phones to kick off a manual process of distribution.
Question by:Tinker12
    LVL 1

    Author Comment

    Outlook 2003 SP2 on XP SP2. Exchange server 2003 Enterprise SP2. Mail is sent from to an internal address that belongs to a DL. If the DL gets the message it distributes it internally company wide. Occasionally the mail will not be sent or quarantined or for some reason not arrive on time. If this is the case, a script will kick off and send a message to the contact list of IM text numbers so that a copy of the message can be manually sent to the internal address.
    Using the rules and alerts tool, it will look fo the message subject line, if found, run 'powershell', create a transform file with text and email it to my phone.  I think what I should do is check and if not there go into a wait, but I dont know what to seed it with if there is no mail.
    LVL 76

    Assisted Solution

    by:David Lee
    Hi, Tinker12.

    From the Outlook perspective this is possible with a bit of scripting, but Outlook would have to be remain logged in for the check to take place.  Is that an option?
    LVL 1

    Author Comment

    Yes, if its to check what is in the box at a certain time or not in the box at a certain time then the mailbox would have to be opened by a user or service.
    LVL 76

    Accepted Solution

    Here's the code for doing this.  Follow these instructions to use it.

    1.  Open Notepad
    2.  Copy the code from the snippet and paste it into Notepad
    3.  Edit the code as needed.  I included a comment where something can/needs to change
    4.  Save the file with a .vbs extension
    5.  Create a scheduled task
    6.  Set the task to run at whatever time you need to check for the message
    7.  Set the task to run this script
    8.  Make sure the task is set to run with an account that has access to the mailbox the message is being sent to
    9.  Test to make sure the script works properly

    The script checks the mailbox for a message with a matching subject.  If it finds one, then it takes no action.  If it does not find one, then it sends a reminder message.

    One note.  Sending a message via Outlook 2003 is going to trigger Outlook's built-in security.  The result is a pop-up dialog-box warning that an application is accessing your mailbox and asking for your permission to allow it to continue.  There is no way to turn security off, but there are ways to work around it.  

    1.  Use ClickYes (, a small utility that'll click the Yes button for you.  It creates a security hole though, since a virus could start sending messages and ClickYes would click the Yes button for it too.  
    2.  Use Redemption (, a COM library that enables code to safely bypass Outlook security.
    3.  Disable Outlook's security features.  I don't recommend this one, but it is an option.

    Const olMailItem = 0
    Const olFolderInbox = 6
    Dim olkApp, olkSes, olkFld, olkItm, olkMsg
    Set olkApp = CreateObject("Outlook.Application")
    Set olkSes = olkApp.GetNamespace("MAPI")
    'Change the profile name on the next line as needed'
    olkSes.Logon "Outlook"
    Set olkFld = olkSes.GetDefaultFolder(olFolderInbox).Items
    'Change the subject of the message to look for on the next line.  It must be an exact match, and it is case sensitive'
    Set olkItm = olkFld.Find("[Subject] = 'My Subject'")
    If TypeName(olkItm) = "Nothing" Then
        Set olkMsg = olkApp.CreateItem(olMailItem)
        With olkMsg
            'Change the reminder subject on the next line'
            .Subject = "Reminder"
            'Change the addressee on the next line and/or duplicate this line to add additional addressees'
            .Recipients.Add ""
            'Change the text of the message on the next line'
            .Body = "Don't forget ..."
        End With
    End If
    Set olkMsg = Nothing
    Set olkItem = Nothing
    Set olkFld = Nothing
    Set olkSes = Nothing
    Set olkApp = Nothing

    Open in new window

    LVL 1

    Author Closing Comment

    Thank you, very elegant. I've gotten a copy of the '' and have found it very useful as well. Once I saw your solution i realised I was way to 'out there'.
    LVL 76

    Expert Comment

    by:David Lee
    Thanks, and you're welcome.  Glad I could help.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    The purpose of this video is to demonstrate how to set up a Mailchimp Template which will let the user create a uniform look for all of their campaigns. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mail…
    The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now