A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Save each e-mail in folder



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 8th 06, 04:02 PM posted to microsoft.public.outlook.program_vba
Jason Morin
external usenet poster
 
Posts: 1
Default 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
Ads
  #2  
Old May 8th 06, 08:36 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default 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

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
can I save addresses to my Personal Folder instead of Contacts LeicesLad Outlook - Using Contacts 8 September 27th 06 04:48 PM
Doesnt save in Send Folder bill Outlook Express 3 April 3rd 06 10:21 PM
auto save attachment to specific folder John 3:16 Outlook and VBA 1 March 27th 06 09:00 PM
How do I save emails in Activities folder? Sue Mosher [MVP-Outlook] Outlook - Using Contacts 4 January 19th 06 05:25 PM
Save to folder no longer remembered JustMe Outlook Express 6 January 12th 06 11:13 PM


All times are GMT +1. The time now is 07:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.