mistux Site Admin
Joined: 25 Jun 2004 Posts: 1042 Location: South Bend, Indiana USA
|
Posted: Wed Apr 13, 2005 5:25 pm Post subject: Save Outlook files in other then BMP format |
|
|
Save Embedded Pictures in Their Original Format
http://www.howto-outlook.com/howto/saveembeddedpictures.htm
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 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.
Make sure the Visual Basic editor is installed
Create macro
The code
Set the Macro Security Level
Create a button for the macro
Using the macro
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.
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. We start up the Visual Basic Editor by going to Tools-> Macro-> Visual Basic Editor. This will open a new screen. Cut and paste the code below to the screen.
Code: | Sub SaveAttachment()
Dim objCurrentItem As Outlook.MailItem
Dim colAttachments As Outlook.Attachments
Dim objAttachment As Outlook.Attachment
Set objCurrentItem = Application.ActiveInspector.CurrentItem
Set colAttachments = objCurrentItem.Attachments
Set strFolderpath = CreateObject("WScript.Shell")
For Each objAttachment In colAttachments
objAttachment.SaveAsFile (strFolderpath.SpecialFolders("Desktop") & "\" & objAttachment.FileName)
Next
Set objAttachment = Nothing
Set colAttachments = Nothing
objCurrentItem.Close (olDiscard)
Set objCurrentItem = Nothing
End Sub |
The code copied in the Visual Basic Editor.
You can now close the Visual Basic Editor.
Set the Macro Security Level
Now that we have created our own macro we must adjust the Macro Security permissions to allow the macro to run. By default the security level for macro's is set to High which means that only signed macro's can run. Since we are not able to sign our own macro we are going to set the Macro Security to Medium which means that we get prompted when we try to run the macro (we only receive a prompt once per Outlook session; restarting Outlook means we'll get prompted once again).
To change the Security Macro Level go to Tools-> Macro-> Security and select Medium
This is the security warning you'll get when the Macro Security Level is set to Medium. Press Enable Macros to enable the macros.
Now that we've created the macro and adjusted the Macro Security Level we must restart Outlook. When we close Outlook we'll get prompted to save our project. Of course we'll choose "Yes".
Create a button for the macro
The easiest way to access and use the macro is to create a button for it. Since the macro only works in messages we open an existing e-mail first. Now follow the instructions below to create a button.
Set the Toolbar in edit mode by going to View-> Toolbars-> Customize...
Select the tab Commands
In the Categories column select Macros
In the Commands toolbar click on Project1 and hold down the mouse button.
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
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)
Press Close to leave edit mode
The Save Attachments icon in the Toolbar
Using the macro
Alright, now that we've gone to all the trouble we can finally save all types of embedded pictures in their original file format. To do this you open the message that contains the embedded pictures. When you click on the Save Attachments button you'll save all the pictures to the Desktop at once and the message will close. In fact the macro will save all possible attachments (except blocked ones) within the message to the Desktop. Say good-bye to converting bmp-'s back to jpg-'s and broken gif-'s! |
|