Forum Home
Press F1
 
Thread ID: 67834 2006-04-07 07:48:00 outlook saveas macro nw3 (126) Press F1
Post ID Timestamp Content User
444657 2006-04-07 07:48:00 Hi

Anybody knows how to write macros in outlook to save all messages in the inbox as .msg files? I have found an example in the help, but it's for open messages only. It does not work on multiple open messages either.

Thanks for the help.

NW3
nw3 (126)
444658 2006-04-07 09:46:00 Hi heres an example. This will create msg files for all the messages within the currently selected folder in Outlook into a folder called C:\Testing. The destination folder (ie C:\testing) must be valid so change this to an existing folder before running.


Sub Example()
Dim i As Long

With Outlook.ActiveExplorer.CurrentFolder

For i = 1 To .Items.Count
.Items(i).SaveAs "C:\Testing\" & .Items(i) & ".msg", olMSG
Next i

End With

End Sub
Parry (5696)
444659 2006-04-07 10:14:00 Thanks.

The code is much simpler.

However punctuations can be a pain. I will modify to remove the punctuations <>?/|"* etc so outlook can save.

Thanks again.

NW3
nw3 (126)
444660 2006-04-07 10:33:00 You might also have to add subfolders as if theres 2 messages with the same subject name an error is going to occur. Parent.Name will give you the folder of the current item.

Outlook.ActiveExplorer.CurrentFolder.Items(i).Pare nt.Name

There should be a way to get each folder then loop through each item in the folder but its not readily appearent. I dont know the Outlook object model so its guesswork.
Parry (5696)
1