Automatic Reply When Your Inbox is Too Full


I was checking Replyz (for those not familiar with Replyz, it’s web app that finds questions on Twitter) last night looking for questions about Microsoft Outlook and stumbled across this one from a tweeter named Nibby Priest.

I’m not sure this is really a good idea, especially in a business setting, but it is possible. It would be nice if you could do this with a rule, but rules don’t have the ability to get a count of the messages already in your inbox. For that we need a script. There’s not much to the script. It’s triggered each time items are delivered to your inbox. The first thing it does is check to see if you’re inbox is over some predefined threshold. In keeping with Nibby Priest’s tweet I’ve set the threshold to 100 messages, but you can change it to any value you want. If your inbox is over the threshold, then the script creates and sends a message back to the sender telling them that you are too busy and to please try again later. You can configure the subject and body of the message to anything you want.

Instructions and Code.

Outlook 2007.

  1. If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
  2. Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
  3. Edit the code as desired. I’ve included a comment where you can make changes.
  4. Click the diskette icon on the toolbar to save the changes
  5. Close the VB Editor
  6. Click Tools > Trust Center
  7. Click Macro Security
  8. Set Macro Security to “Warnings for all macros”
  9. Click OK
  10. Close Outlook
  11. Start Outlook. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run. Say yes.

Outlook 2010.

  1. If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
  2. Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
  3. Edit the code as desired. I’ve included a comment where you can make changes.
  4. Click the diskette icon on the toolbar to save the changes
  5. Close the VB Editor
  6. Click File and select Options
  7. When the Outlook Options dialog appears click Trust Center then click the Trust Center Settings button
  8. Click Macro Settings
  9. Select either of the two bottom settings (i.e. “Notifications for all macros” or “Enable all macros (not recommended; potentially dangerous code can run)”. The choice of which to choose is up to you. If you select “Notifications”, then you’ll be prompted at times to enable macros. If you pick “Enable all” then there’s a chance that a malicious macro could run. It’s a question of how much risk you want to assume.
  10. Click Ok until the dialog-boxes have all closed
  11. Close Outlook
  12. Start Outlook. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run. Say yes.
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    'On the next three lines edit the values as desired.
    Const RESPONSE_THRESHOLD = 100
    Const RESPONSE_SUBJECT = "Really Busy"
    Const RESPONSE_MESSAGE = "I got your email.  I'm really swamped right now, so please try again later."
    Dim arrEID As Variant, varEID As Variant, olkItm As Object, olkMsg As Outlook.MailItem
    If Session.GetDefaultFolder(olFolderInbox).Items.Count >= RESPONSE_THRESHOLD Then
        arrEID = Split(EntryIDCollection, ",")
        For Each varEID In arrEID
            Set olkItm = Session.GetItemFromID(varEID)
            If olkItm.Class = olMail Then
                Set olkMsg = Application.CreateItem(olMailItem)
                With olkMsg
                    .Subject = RESPONSE_SUBJECT
                    .BodyFormat = olFormatHTML
                    .HTMLBody = RESPONSE_MESSAGE
                    .Recipients.Add olkItm.SenderEmailAddress
                    .Send
                End With
            End If
        Next
    End If
End Sub
Advertisements

4 comments on “Automatic Reply When Your Inbox is Too Full

  1. I love this! It proves if you ask a question on Twitter someone will respond with a legitimate answer. Way to go Lee! You are on my must read list of blogs now. Thanks again, but like you said, I don’t know if my insurance clients would appreciate getting these “busy” messages. 🙂

    • Thanks and you’re welcome. I thought it was an interesting idea, even if it’s not practical in all situations.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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