Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Outlook & SubFolders coding

I am coding to retrieve emails from Outlook (date, subject, body, sender,
etc.) and store the info in excel for later processing.

My code works fine until I want to process an Outlook folder that is not on
the same level as the 2 levels I have coded below.
Set myFolderToProcess = olMAPI.Folders("MyName").Folders("Inbox").


I can modify the code to read:
Set myFolderToProcess =
olMAPI.Folders("MyName").Folders("Inbox").Folders( "Sales")
to add the 3rd level and it works - but this cannot be the correct way to do
it.

What is the proper way to code this when you have folders that may be 2, 3,
4 levels deep (and may vary of # of levels each time)?

Thank you,
MSweetG222

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Outlook & SubFolders coding

The Folders property of an Outlook folder returns a collection of all the
subfolders of that folder (when you don't enter the name after ".Folders".
Then you can use a For Each....Next loop to set references to each of those
folders.

Steve


"MSweetG222" wrote in message
...
I am coding to retrieve emails from Outlook (date, subject, body, sender,
etc.) and store the info in excel for later processing.

My code works fine until I want to process an Outlook folder that is not
on
the same level as the 2 levels I have coded below.
Set myFolderToProcess = olMAPI.Folders("MyName").Folders("Inbox").


I can modify the code to read:
Set myFolderToProcess =
olMAPI.Folders("MyName").Folders("Inbox").Folders( "Sales")
to add the 3rd level and it works - but this cannot be the correct way to
do
it.

What is the proper way to code this when you have folders that may be 2,
3,
4 levels deep (and may vary of # of levels each time)?

Thank you,
MSweetG222



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Outlook & SubFolders coding

Thank you Steve.

MSweetG222
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Outlook & SubFolders coding

I figured it out. I just make a loop and keep the folder variable refer'ing
to itself.
Where myEmailFolderPath = "Inbox\Sales"

Set myFolderToProcess = olMAPI.Folders("MyName").
myEmailFolderPath = Split(EmailPath, "\")

For m = 0 To UBound(myEmailFolderPath)
Set myFolderToProcess = myFolderToProcess.Folders(myEmailFolderPath(m))
Next m

With this method, I can have as many layers as I need.
Thanks

Thx
MSweetG222


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Outlook & SubFolders coding

I need to do exactly that!

I there any chance you would share the code you are using? Please!

"MSweetG222" wrote:

"I am coding to retrieve emails from Outlook (date, subject, body, sender,
etc.) and store the info in excel for later processing."




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Outlook & SubFolders coding

Nevermind got my head round it in the end thanks to this forum leading me to
this page of Dicks Clicks: http://www.dicks-clicks.com/excel/olRetrieving.htm

"Damon" wrote:

I need to do exactly that!

I there any chance you would share the code you are using? Please!

"MSweetG222" wrote:

"I am coding to retrieve emails from Outlook (date, subject, body, sender,
etc.) and store the info in excel for later processing."


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel VBA coding - Outlook and Shut down issue [email protected] Excel Worksheet Functions 0 October 1st 06 06:29 PM
linking Outlook email folders/subfolders to excell spreadsheets Elvio Excel Worksheet Functions 0 July 31st 06 07:38 PM
copy subfolders, replace text in files and save files in copied subfolders pieros Excel Programming 0 November 1st 05 12:08 PM
Exporting Excel Schedule to Outlook Calendar Subfolders littlegreenmen1[_6_] Excel Programming 1 July 7th 05 08:30 PM
What 's wrong with the coding? -- about using outlook to send attachment in excel Terry Excel Programming 1 February 5th 04 10:31 PM


All times are GMT +1. The time now is 06:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"