One of the restrictions of Exchange Server as a mail system is that while every mailbox can receive mail from several addresses, it can only send mail from a single default address. Recently, one of our clients decided they’d like to raise the prominence of their various brands by having mail sent to and from the staff at those brands addressed by the brand name, and they asked us if we could find a way to do this. I enjoy technical challenges, so we had a big think and came up with the following plan.
Each person at the company already had an email address of the form John.Smith@BrandA.com, and we found we could create a Distribution List (DL) in Active Directory called “John Smith (Brand B)”, give it the address John.Smith@BrandB.com, make John Smith the only member of that DL and give him full control of it. Email sent to this new address would be relayed to John Smith’s inbox, but would still appear there as addressed to “John Smith (Brand B)”. What’s more, if John wants to send mail from that address, he just has to type the name “John Smith (Brand B)” into the From: box. Since each person has full control of their DL, they’re allowed to send from that address and the recipient will see that address on the received mail.
This seemed like a workable plan, but it’s still a bit of a pain to type “John Smith (Brand B)” into the From: box, and Outlook won’t help you to get this right even when you’re replying to an email sent to “John Smith (Brand B)”, as it would have done if you’d used separate POP3 accounts. We did consider creating separate POP3 accounts on the Exchange Server, but that would require creating multiple mailboxes for each person, and the company’s anti-virus and spam filter service – GFI MailEssentials – charges by the mailbox, so costs would quadruple. Using a DL doesn’t require any extra mailboxes.
To make it easier to send mail through different addresses, we wrote a small add-in for Outlook 2003 using Visual Studio Tools for Office 2005 Second Edition (VSTO2005SE), which adds an extra button to the Compose Email form that lets the user choose which of their addresses to use. VSTO2005SE has a simple model for connecting your add-in to the host application: you get an object called ThisApplication, which has Startup and Shutdown methods, and then you call your code from those methods and most of the other aspects of the add-in will be taken care of for you. There’s a VSTO Runtime module to install on the client PCs in addition to your add-in code, but that only needs to be done once, no matter how many VSTO add-ins you install. There’s no need to create COM Shims in C++ for security either, because the VSTO Runtime deals with security for the most part – just register your add-in through the Code Access Security system in the .NET Framework.
Now, the worst thing about writing add-ins for Outlook is the need to deal with the different Explorers and Inspectors. The main Outlook window itself is an Explorer, which shows the contents of one particular folder. Since you can right-click on any folder and choose to “Open in New Window”, you may have multiple Explorers open at the same time. When you double-click on an item, it opens in an Inspector and, because you can inspect multiple items at the same time, you can also have multiple Inspector objects open. Each Explorer and Inspector gets its own set of toolbars and buttons, and if you want to add new buttons to the toolbars on the Inspectors you have to find a way to keep track of them as they’re created.