Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

Monitor for mail NOT in the inbox

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.
  • 3
  • 3
2 Solutions
Tinker12Author Commented:
Outlook 2003 SP2 on XP SP2. Exchange server 2003 Enterprise SP2. Mail is sent from whatcounts.com 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 whatcounts.com 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.
David LeeCommented:
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?
Tinker12Author Commented:
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.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

David LeeCommented:
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 (http://www.contextmagic.com/express-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 (http://www.dimastr.com), 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 "someone@company.com"
        '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

Tinker12Author Commented:
Thank you, very elegant. I've gotten a copy of the 'checkyes.pro' and have found it very useful as well. Once I saw your solution i realised I was way to 'out there'.
David LeeCommented:
Thanks, and you're welcome.  Glad I could help.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now