0

i tried several approaches to perform a specifc search, but somehow I do not succeed. This is some pseudocode that (hopefully) explains what I am after:

Mail of interest = new received mail
Search term = communicationID of mail of interest
Mainfolder = inbox
Find all subfolders in Mainfolder
Targetfolder  = FoundFolder 1
Find Searchterm in Targetfolder 
If Searchterm was found then move mail of interest to Targetfolder and exit
If Serchterm was not found continue in next Foundfolder
If no further results exist leave mail of interest in inbox and exit.

I manage to fetch the "mail of interest" and I manage to move it once I identified a relevant folder, but I am struggling with the identification of the subfolders and to Loop through them.

The Intention is to "not search" in the inbox itself but only in the subfolders.

I am quite new to outlook VBA, so If anyone could help with a code snippet or with some explanation how to DIM which variables and how to construct the search for the Targetfolders and Looping through those Targetfolders one by one that would be great.

Thanks Ralf

PS: Talking about outlook 2013

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Ralf
  • 9
  • 3
  • This answer of mine may give you a start: [Update excel sheet based on outlook mail](http://stackoverflow.com/a/8699250/973283). It is a tutorial that starts by showing how to access Outlook folders and sub-folders. – Tony Dallimore Oct 31 '15 at 16:42

1 Answers1

0

It is not clear what code you have now...

Anyway, the GetDefaultFolder method of the Namespace class returns a Folder object that represents the default folder of the requested type for the current profile; for example, obtains the default Calendar folder for the user who is currently logged on. The GetDefaultFolder method of the Store class is similar to the GetDefaultFolder method of the NameSpace object. The difference is that this method gets the default folder on the delivery store that is associated with the account, whereas NameSpace.GetDefaultFolder returns the default folder on the default store for the current profile.

You may find the Getting Started with VBA in Outlook 2010 article helpful.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • This was not precisely what I was after, but the article was helpful anyway. Thanks for your time! – Ralf Nov 17 '15 at 14:09