Accessing .pst folder in outlook using VBA Code

A

Abhijat

Hi group,
I need some help regarding accessing .pst folder using VBA. I want to
replicate the code code below (done for Inbox) for a folder in my .pst
(the path of .pst file is say "C:\Outlook\Personal Folders.pst"

Set ns = appOl.GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
For Each Item In Inbox.Items
---
---
Next Item


Any help in this regard with be truly appreciated.

Best Regards,
Abhijat
 
M

Michael Bauer [MVP - Outlook]

If the file isn't opend yet, see the AddStore method. Then the store is
available in the Namespace.Folders collection.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Mon, 12 Oct 2009 09:29:22 -0700 (PDT) schrieb Abhijat:
 
A

Abhijat

Hi Michael,
Thanks a lot.
Yes. I can open the .pst file as
ns.AddStore ("P:\Outlook\Personal Folders.pst"). So the code now
becomes:
Set ns = appOl.GetNamespace("MAPI")
ns.AddStore ("P:\Outlook\Personal Folders.pst")

Its fine till here.

My problem is : my code is not able to point at a sub-folder (call it
"TEST") which is made in the .pst file.

Just to reiterate:
I can have a code that can point at the "Test" sub-folder under my
server Inbox like this:
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set newInbox = Inbox.Folders("Test")

I am looking for a code that may point at the "TEST" sub-folder lying
under my .pst file.

Thanks for your help again!

Best regards,
Abhijat.
 
M

Michael Bauer [MVP - Outlook]

The store has a Folders collection, that's where you start to find your
folders by name.

Unfortunately, AddStore doesn't return the added folder. So, you need to
find it in Session.Folders, maybe by comparing what has been there before
and what's new. You cannot rely on the index.

It's a lot easier with the Redemption (www.dimastr.com). Its AddPSTStore
function does return the added store.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Tue, 13 Oct 2009 03:46:52 -0700 (PDT) schrieb Abhijat:
 
A

Abhijat

Hi Michael,
Thanks a lot.
I think I need to work on my skills before I can use your suggestion.
Once again, thanks a lot for your time and guidanace.

Best regards,
Abhijat.
 

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