Save Embedded Pictures in Their Original Format

You've probably come across this at least once; You receive a nicely HTML formatted message with embedded pictures so the sender can tell the story with the pictures and when you try to save the pictures you can only save them as a bmp-file. Or; you receive a fun e-mail with an animated gif-file and when you try to save it you can only save or copy it as a bmp-file which will of course break the animation.

This How To article explains how you can save the embedded pictures in their original file format.

This issue finally got fixed in Outlook 2010 but you can still use this macro to save all the embedded images of a message at once (something that no version of Outlook lets you do currently.

Make sure the Visual Basic editor is installed

Since we are going to create a macro from code you must have the Visual Basic editor installed (which is the default). If you don't have it installed you can install it by Control Panel-> Add/Remove Programs-> select your Office version-> button change. Now setup will start. Here you choose for Add or Remove Features-> Select "Choose advanced customization of applications" (Outlook 2003). In the list you get expand Microsoft Office-> Office Shared Features-> Visual Basic for Applications and set it to Run form My Computer. Press "Update" to install. You might need to insert your CD during setup.

VB Editor menu
This is where you can find the Visual Basic Editor when you have it installed

Create Macro

As I already provide you with the code, creating the macro is easy. The code has been tested with Outlook 2003 on Windows XP and Outlook 2007 on Windows Vista but should work on previous versions as well.

We start up the Visual Basic Editor by going to Tools-> Macro-> Visual Basic Editor. This will open a new screen. Choose Insert-> Module to create a new module dedicated to this macro. Select the newly created module in the left pane and rename it to "SaveAttachments" by changing the Properties value in the pane underneath. Copy and paste the code below to the module.

Click in the area above and press CTR+A to select all. Press CTRL+C to copy the code

VB Editor (click on image to enlarge)
The code copied in the Visual Basic Editor. (click on image to enlarge)

Since this macro also uses Windows functionality to prompt you for a folder location we must add the reference to the project. To do this choose Tools-> References… and select Microsoft Shell Controls And Automation. After this press OK.

Now we debug the code by choosing Debug-> Compile Project1. You shouldn't be getting errors if you've done everything correctly.
If you do get errors retrace your steps and also verify that any previous code you might have in ThisOutlookSession is correct. Debug until you've solved the errors (the code provided works correctly without any modifications).

To be able to run the code without setting your macro security level to medium I recommend that you sign your code which is a very easy process and only takes a minute.

Create a button for the macro

You can run the macro through Tools-> Macros… -> select the SaveAttachment macro and then press Run. However the easiest way to access and use the macro is to create a button for it. Since the macro works on the selected item we can create the button in the main Outlook window. Follow the instructions below to create a button.

  1. Set the Toolbar in edit mode by going to View-> Toolbars-> Customize…
  2. Select the tab Commands
  3. In the Categories column select Macros
  4. In the Commands toolbar click on Project1.SaveAttachment and hold down the mouse button.
  5. Drag the icon to a location on the Toolbar so the pointer will loose the cross and release the mouse button to drop it in that location
  6. Right click the icon to change the name and to assign it a button image you like (if you want to learn more about editing Toolbar buttons click here)
  7. Press Close to leave edit mode

Save Attachments
The Save Attachments icon in the Toolbar. Curious what my Running Man icon does?

Using the macro

Alright, now that we've gone through all the trouble we can finally save all types of embedded pictures in their original file format. To do this you select the message that contains the embedded pictures. When you click on the Save Attachments button you'll save all attachments with a date and time stamp to a folder of choice. Note that it doesn't save blocked attachments.

Say good-bye to converting bmp-s back to jpg-s and broken gif-s!

If you don’t like to work with VBA or if you are looking for a more advanced way to manage picture attachments in Outlook, I can recommend using the Picture Attachments Wizard addin from Collaborative Innovations. Besides extracting the pictures from an email, it also offers the option to display attached (instead of embedded) pictures as thumbnails within a mail, directly starting a slideshow and quite some more functionality.