Re: Extract mail details from Outlook 2000+ to Excel

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



You can't use it to exclude certain folders but you can use the NameSpace.PickFolders method to bring up the standard Outlook folder picker dialog.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"PangoKen" <leejkennedy@xxxxxxxxxxxx> wrote in message news:1176287759.447150.105080@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi

I have created a report that will copy all email details in a outlook
folder (receivedtime, LastModificationTime, sender name etc.) to
excel. Currently the code asks me to select a folder to report on, but
I would like to extend this to include sub-folders as well. Can anyone
tell me an easy way to specify that sub-folders are included (and that
sub-folders named 'Completed' are excluded)?

The code I'm using to select the folder and work with the info is:

' 1) ask me to select a folder containing received mail
Set ns = Application.Session
Set fld = ns.PickFolder
If Not fld Is Nothing Then

'a) count the mail items in the folder
intTotalItems = fld.Items.Count

'3) set the location of the storage file and
' create the Excel work***
' **code removed**

'b) identify which folder we are working with
ws.Cells(1, 1) = "Items in folders: " & fld

'4) loop through all mails in the selected Outlook folder

intRow = 4
For Each itm In fld.Items
DoEvents
If itm.Class = olMail Then

' 5 )write all the senders email adr, senders name, emails
' subject received time into this single created file
' fill in the rows with the message data
Set msg = itm
' this next line doesn't work with outlook 2000 but
' does with outlook 2003
' ws.Cells(intRow, 1) = msg.SenderEmailAddress
ws.Cells(intRow, 2) = msg.SenderName
ws.Cells(intRow, 3) = msg.Subject
ws.Cells(intRow, 5) = msg.ReceivedTime
ws.Cells(intRow, 6) = msg.LastModificationTime
etc.


thank you for your help

Lee


.


Quantcast