alex in a nutshell

December 19, 2011

Refreshing unread counts for IMAP folders in Outlook 2007 or 2010

Filed under: — Alex Salamakha @ 11:30 PM

I’ve got three Google Apps accounts with IMAP interface and I use Outlook to manage my emails.

It’s a great tool, but it has an annoying feature – when it starts it doesn’t display unread counts for IMAP accounts. So you have to physically click on every IMAP account to see whether you have any new messages or not. Pretty horrible, if you ask me.

Thankfully, it’s not that hard to solve this problem.

First of all, enable Developer tools:

Right-click Outlook toolbar, then choose Customize the Ribbon menu

then tick Developer toolbar:

You will now see Developer toolbar

Click on Macros button.

In the new window type GoThroughAllAccounts or whatever name you fancy and click Create button

In the editor window type

Sub GoThroughAllAccounts()
For Each Account In Session.Accounts
//iterate through accounts and go into each folder
Set Application.ActiveExplorer.CurrentFolder = Account.DeliveryStore.GetDefaultFolder(olFolderInbox)
Next
End Sub

In the tree on the left click on Microsoft Outlook Object, choose ThisOutlookSession and double-click it. A new editor window will appear.

In the window choose Startup event from the drop-down on top-right and type

Call GoThroughAllAccounts

in the body of the sub-routine

Save your script and close the script editor.

Now we need to set permissions for your script to run on startup.

In Outlook click on File >> Options >> Trust Center and then press Trust Center settings button

Click on Macro Settings link on the left and choose one of the two options:

1) Notifications for all macros you will have to press Enable macros every time you start Outlook

2) Enable all macros – it will work without bothering you, but you have to be more cautious with this settings as you may end up getting viruses.

I use option 2).

 

7 Comments »

  1. This looks like exactly what I need, however, I am trying to do this in Outlook 2007 and getting the following error message at Outlook Startup. My VBA/macro knowledgeable is minimal.

    Run-time error ‘438’:
    Object doesn’t support this property or method

    When I press “debug”, this line is highlighted (it is on one line in the editor)

    Set Application.ActiveExplorer.CurrentFolder = Account.DeliveryStore.GetDefaultFolder(olFolderInbox)

    Any ideas?
    Thanks

    Dana Sims (dsims9999-at-gmail.com

    Comment by Dana — January 31, 2012 @ 3:19 AM

  2. Legend. This really helped me out – I actually added it to the NewMail in ThisOutlookSession too so it runs through after the Send/Receive cycle. Really appreciate the solution 😀

    Comment by Dave — February 18, 2012 @ 8:44 AM

  3. Thank you for providing this tip. However, I am getting exactly the same error as Dana in the first comment (Run-time error 438), also in Outlook 2007. Any help would be appreciated.

    Comment by John — July 23, 2012 @ 5:02 AM

  4. Works great, thanks for sharing this !
    What code would it take to collapse all accounts after running the macro?

    Comment by Jan — November 20, 2012 @ 2:03 AM

  5. This is great, searched for ages for a solution and none of the other ones worked, thanks very much!

    Comment by Nick — May 29, 2013 @ 12:24 AM

  6. Excellent, thanks for this – exactly what was needed.

    @Dave – I don’t think you need to run after ever send/receive cycle since the unread count updates correctly when the folders are expanded, so unless you close any once this has run you’ll be fine.

    Comment by Paul — June 6, 2013 @ 8:11 PM

  7. Thank you very much!! Brilliantly simple.
    @Dave – Thanks very much as well. Perfect for my situation.

    Comment by Rob Donoho — October 24, 2013 @ 10:18 PM

RSS feed for comments on this post. TrackBack URL

Leave a comment

Copyright © 1997-2017 Alexei Salamakha. All rights reserved
email: alex@salamakha.com    Alex Salamakha on Facebook    Alex Salamakha on LinkedIn