Mobile Email Notifications


Today, most of us have smartphones that can send/receive email from anywhere. But what if you don’t have a smartphone? Or perhaps you do have a smartphone, but your company has a policy that prohibits accessing the corporate email system from it. Let’s say that you have a cell phone, not a smartphone, or you have a personally owned smartphone, and that you will be away from your desk for a while. While you’re out, you’d like to know if a particular message has arrived. That’s the situation one commenter found himself in and approached me about.

Outlook does have a built-in solution for this scenario, which is to use a rule that sends a message based on a condition. The rule watches for messages that meet a certain condition. When one arrives, it would create an email and send it to the email account on your smartphone, if that’s what you have, or as a text message to a regular cell phone. The problem with this solution is that you have to use a message template and templates don’t allow you to pass on any of the message’s details. Assume that you want a notification for any message coming from a person on your project team. A message from one of them comes in and the rule sends the notification. Because the notification is a template, you don’t have any clue who sent the message that triggered the rule, or what the subject is. All you know is that you got a message from someone on your project team. That’s not very useful.

The solution to this scenario is a macro. You’ll still use a rule to watch for the subject messages, but instead of the rule sending a canned message, the macro will send a message that includes the sender and subject information of the message that triggered the rule. The macro also allows you to specify whether you want the notification as an email or as a text message. Actually both will go out as an email, the difference being the format and length of the notification. Emails will go in HTML format while a text message will go as plain text and will be briefer and to the point. Consult this Wikipedia article for a list of email-to-SMS gateways. It shows how to format the email address for your cellular service provider. If your cellular provider isn’t listed, then you’ll either have to have a smartphone and use the email option, or find an email-to-SMS gateway you can use.

Adding the code to Outlook.

  1. Start Outlook
  2. Press ALT+F11 to open the Visual Basic Editor
  3. If not already expanded, expand Microsoft Office Outlook Objects
  4. If not already expanded, expand Modules
  5. Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
  6. Copy the code from the code snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
  7. Edit the code as needed. I included comments where changes are required
  8. Click the diskette icon on the toolbar to save the changes
  9. Close the VB Editor
Sub SendNotification(Item As Outlook.MailItem)
    'On the next line set the value to True if you want the notification as an SMS, False if you want it as an email
    Const SEND_AS_SMS = True
    'On the next line enter the email address of your SMS account (if using SMS) or of your smartphone's email account
    Const EMAIL_ADDR = ""
    Dim olkMsg As Outlook.MailItem
    Set olkMsg = Application.CreateItem(olMailItem)
    With olkMsg
        .Recipients.Add EMAIL_ADDR
        If SEND_AS_SMS Then
            .BodyFormat = olFormatPlain
            .Subject = "New Msg"
            .Body = Item.SenderName & vbCrLf & Item.Subject
            .BodyFormat = olFormatHTML
            .Subject = "New Message"
            .HTMLBody = "You just received a message from <b>" & Item.SenderName & "</b> with a subject of <b>" & Item.Subject & "</b>"
        End If
    End With
    Set olkMsg = Nothing
End Sub

Using this solution.

  1. Create a rule that fires for the messages you want notifications for.
  2. Set the rule’s action to run a script and select this macro as the one to run.

10 comments on “Mobile Email Notifications

    • This script will only work with Outlook. I don’t use or know much about other email clients (e.g. Thunderbird), so I don’t know if there are other clients that have a scripting capability.

    • Hi, Amol_Mane.

      If you want to forward the entire message, then you don’t need this solution at all. Just create a rule that forwards messages to another email address.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s