Accessing .pst folder in outlook using VBA Code

  • Thread starter Abhijat
  • Start date Views 9,526
A

Abhijat

#1
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.

Abhijat
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
#2
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

Am Mon, 12 Oct 2009 09:29:22 -0700 (PDT) schrieb 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.

> ,
> Abhijat
 
A

Abhijat

#3
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.

On Oct 12, 10:18 pm, "Michael Bauer " <m...@mvps.org
wrote:
> 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

>   >   >  

> Am Mon, 12 Oct 2009 09:29:22 -0700 (PDT) schrieb 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.

>
> > ,
> > Abhijat-


 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
#4
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

Am Tue, 13 Oct 2009 03:46:52 -0700 (PDT) schrieb 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.

> On Oct 12, 10:18 pm, "Michael Bauer " <m...@mvps.org
> wrote:
> > 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
>

>>   >>   >>  
>

>> Am Mon, 12 Oct 2009 09:29:22 -0700 (PDT) schrieb 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.

> >
> >> ,
> >> Abhijat-

>

>
 
A

Abhijat

#5
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.

On Oct 13, 9:14 pm, "Michael Bauer " <m...@mvps.org
wrote:
> 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

>   >   >  

> Am Tue, 13 Oct 2009 03:46:52 -0700 (PDT) schrieb 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.

>
> > On Oct 12, 10:18 pm, "Michael Bauer " <m...@mvps.org
> > wrote:
> >> 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

>
> >>   > >>   > >>  

>
> >> Am Mon, 12 Oct 2009 09:29:22 -0700 (PDT) schrieb 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.

>
> >>> ,
> >>> Abhijat-

>
> >-


 

Similar threads

Top