To automate MS Outlook, you usually use macros (written in Visual Basic for Applications aka VBA). But often, company security policies denies access to Outlook Macros. But you can still use VB Script aka VBS.

Here I show two scripts that copy parts of an Outlook email to the Windows clipboard. A third script forwards all selected mails to an email address. I am not an VBS expert but have put them together from various other scripts and solutions around the web.

I use these scripts with Windows XP and Outlook 2003.

Copy mail content to clipboard

I use Emacs org-mode as an TODO-List and journaling application. When I want to reference an email in a task or journal entry I can either quote the email or link to it. The easiest way is to get the appropiate content into the clipboard and yank it in the org-mode buffer.

As far as I know, the Windows clipboard is directly available to VBA scripts. But not so for VB scripts. According to the net, there are several workarounds. The one I use here makes use of the Internet Explorer Object: it opens the „about:blank“ page and gets access to the clipboard through its „parentwindow“ property. To avoid a security question I added „about:blank“ to the list of local sites in the Internet Explorer security settings.

In org-mode you can have links and using org-outlook you can have links to specifc outlook message. You need the GUID of the specific message. One caveat here: that GUID changes when you move that message to a different folder.

Mass forward emails

The Outlook API provides an method to forward a mail. It behaves just like you would hit „forward“ in the GUI. Fill the recipient with a mail address and call the mail’s „send“ method. But wait: there will be a security questions that will ask you to confirm that you really want to send this mail. You have to wait 5 seconds to confirm it. This slows down mass forwarding… The following script loops through all selected mails in Outlook and forwards them.

I have seen one trick that claims to await the 5-second-confirmation-dialog: it uses some other VB object to simulate a „Alt-S“ keystroke so that it seems the user himself press „Send“ in the GUI. Don’t know if that works.

Assign keyboard shortcuts

I created shortcuts on the desktop to these scripts. For the first two scripts I assigned keyboard shortcut (C-F7 and C-S-F7 resp.) That way I do not need to navigate to the script to execute it.