Count the number of folders in your mailbox with Outlook VBA

A coworker asked me today if I knew how to count up the total number of folders in his mailbox, in the process of troubleshooting a bug related to having a large number of folders. I had an old script that recursed through a mailbox to count the total number of items (also written for…

2

Ideas for new Outlook macros?

An email with a coworker who was recently acquired and is getting accustomed to Outlook after years with PINE reminded me that it’s been a while since I wrote any Outlook macros. Plus, I just need an excuse to write some code, I haven’t written any in several months and that part of my brain is congealing…

14

Quickly view the internet headers of a message in Outlook

Just about anyone who runs mail servers needs to look at headers from time to time. This is especially true during the development of product such as Exchange, as we track down and fix bugs. I wrote this little macro to make that a little easier. Select a message, click the button to run the…

8

A poor man's mail merge

Several times in the last few months I’ve needed to send the exact same mail content to a list of people, but each mail had to be separately addressed, for the following reasons: I am expecting each recipient to reply and continue the thread with me. This way there’s no risk of “Reply All” going…

3

"You forgot to attach the file!"

Yikes, it’s been a while since I’ve posted… and to think for the first 9 months of this blog, I think I posted every single day. I guess I just don’t have that much content and I wore it out early… but in reality I think it’s more due to my new working arrangement and…

7

How to add a custom toolbar button and give it a tooltip

Bob asked in the comments on this article if it’s possible to add a tooltip to a button. Here’s one way to do it programmatically for your own buttons. The below example adds a custom button to the standard toolbar and assigns it a tooltip. Note that the button does not actually do anything in…

5

How to add a toolbar button & hotkey to empty the junk e-mail folder in Outlook 2003

I saw this discussion on Jonathan’s blog, so here’s one option: #1: Follow the instructions in this article with this code: Public Sub EmptyJunkEmailFolder()     Dim outapp As Outlook.Application    Set outapp = CreateObject(“outlook.application”)    Dim olitem As Object    Dim fldJunk As Outlook.MAPIFolder        Set fldJunk = outapp.GetNamespace(“MAPI”).GetDefaultFolder(olFolderJunk)    For Each olitem In fldJunk.Items        olitem.Delete    Next        Set…

0

How to change the icons on custom toolbar buttons

I’ve blogged previously about how to create a new toolbar button that runs a macro you’ve written. Another neat trick about this is to change the icon on this custom toolbar button to be more relevant. I have custom macros to do things such as: Create a task from the selected emails Move mails to…

0

How to assign a macro to a toolbar button in Outlook

1. View | Toolbars | Customize2. On the Commands tab, click Macros on the left-hand side3. Drag the appropriate macro to the standard toolbar (say, next to the “Send/Receive“ button)4. Right click on the button and change the Name field if you want to shorten the text or assign a different accelerator key5. Click Close…

7

How to add VBA macro code to Outlook and run it once

1. Start Outlook2. Tools | Macros | Security3. Choose “Medium”, which will prompt you on whether or not you want to run macros (VBA). You may need to restart Outlook at this point in order for that setting to take effect.4. Tools | Macros | Visual Basic Editor5. Doubleclick on This Outlook Session on the…

3