Yeah, sorry - I used "NameSpace" as an object instead of using a variable
name. So you would use this:
Dim objNS As Outlook.Namespace
Set objNS = Application.GetNameSpace("MAPI")
This object contains a Folders collection which represents all loaded .pst
files, as well as Exchange Mailboxes and Public Folders. So if you had two
..pst files loaded, Folders.Count would equal 2. To get a reference to any of
the .pst files, either set a reference to variable by calling the
Folders.GetFirst or Folders.GetLast method (i.e. Set objFolder =
objNS.Folders.GetFirst), or call it by name (Set objFolder =
objNS.Folders("PST1")) or odinal number (Set objFolder = objNS.Folders(1)).
These methods only get you the very top folder in the pst hierarchy - which
contains NO items! All the default folders are one level down:
Set objTopLevelFolder = objNS.Folders("PST1")
Set objInbox = objTopLevelFolder.Folders("Inbox")
Set objInboxSubFolder = objInbox.Folders("Subfolder of Inbox")
And keep going for deeper nested folders. Does this make sense?
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/ckytm
Job:
http://www.imaginets.com
Blog:
http://blogs.officezealot.com/legault/