Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Save each e-mail in folder (http://www.outlookbanter.com/outlook-vba/14073-save-each-e-mail-folder.html)

Jason Morin May 8th 06 04:02 PM

Save each e-mail in folder
 
Hi-
I'd like to burn about 150 e-mails in a folder to a CD. I'm looking for some
code that will loop through 1 folder and save each e-mail as a *.htm file
into a folder on my desktop. Then I'll burn those htm files to the CD.

If an e-mail has an attachment, it can be disregarded.

Thanks your for help
Jason
Outlook 2003, WinXP

Eric Legault [MVP - Outlook] May 8th 06 08:36 PM

Save each e-mail in folder
 
Try this macro:

Sub SaveEmailsToDisk()
On Error Resume Next

Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder, objItems As Outlook.Items
Dim objItem As Object
Dim strSavePath As String, objMailItem As Outlook.MailItem

Set objNS = Application.GetNamespace("MAPI")

'Select folder containing e-mails
Set objFolder = objNS.PickFolder
If objFolder Is Nothing Then Exit Sub

strSavePath = "C:\Temp"

'FIND ALL E-MAIL MESSAGES IN THE CURRENT FOLDER
Set objItems = objFolder.Items
For Each objItem In objItems
If objItem.Class = olMail Then
If objItem.Attachments.Count = 0 Then
'only process e-mails without attachments
Set objMailItem = objItem
'Be wary of invalid file name characters in Subject line!
objMailItem.SaveAs strSavePath & objMailItem.Subject &
".htm", OlSaveAsType.olHTML
End If
Set objMailItem = Nothing
Set objItem = Nothing
End If
Next

Set objItems = Nothing
Set objFolder = Nothing
Set objNS = Nothing
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Jason Morin" wrote:

Hi-
I'd like to burn about 150 e-mails in a folder to a CD. I'm looking for some
code that will loop through 1 folder and save each e-mail as a *.htm file
into a folder on my desktop. Then I'll burn those htm files to the CD.

If an e-mail has an attachment, it can be disregarded.

Thanks your for help
Jason
Outlook 2003, WinXP



All times are GMT +1. The time now is 06:44 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com