How do I refer to a subfolder in other .pst file

G

Guest

Hi,

I use OL2003 and have several pst files for different accounts, subjects etc.

I need a code which strips the attachment from incoming emails which are
first moved (through OL rules) to certain pst file. So, I need to refer to a
subfolder from other pst file than the default one.

Dim oApp As Application
Dim oNS As NameSpace
Dim atm As Attachment
Dim sub_subfolder, subfolder, inbox As MAPIFolder
Dim olMail As Outlook.MailItem
Set oApp = New Outlook.Application
Set oNS = oApp.GetNamespace("MAPI")
Set ofolder = oNS.GetDefaultFolder(olFolderInbox)
Set sub_subfolder = ofolder.Folders("xxxx").Folders("yyyy")

This is the begining of the code.

Any help please?

Thanks and regards,
 
S

Sue Mosher [MVP-Outlook]

You're on the right track using the Folders collection, but you need to start at the top with the Namespace.Folders collection. To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you, such as that at http://www.outlookcode.com/d/code/getfolder.htm

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top