Accessing .pst folder in outlook using VBA Code

Status
Not open for further replies.
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.

Abhijat
 

Michael Bauer

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

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
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

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-

>
> >-


 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
RBLampert Accessing Outlook accounts from multiple computers Using Outlook 8
E Accessing shared outlook folder doesn't work since switch to new outlook/excel Outlook VBA and Custom Forms 11
J Accessing calendar items for Resource Mailboxes Outlook VBA and Custom Forms 2
S Outlook [Online - Office365] perfomance is getting affected when accessing the mails using Redemptio Using Outlook 1
J Accessing Hotmail accounts with Outlook 2016 Using Outlook 3
n2b Accessing Plain Text Draft Without Outlook Using Outlook 3
G Issues with accessing Outlook Contact Picture with VBA Outlook VBA and Custom Forms 4
M Accessing ExpiryTime property Outlook VBA and Custom Forms 1
M Accessing BCM with Excel / Running Reports BCM (Business Contact Manager) 1
C Problem accessing events for folder "username" Server Threw Exception Calendar Printing Assistant 1
P accessing custom task pane with Outlook ActiveInspector Using Outlook 1
mikecox Accessing Outlook on my Win7 desktop from Win8 laptop Using Outlook 1
A "Unable to display the folder" error when accessing Group mailbox Using Outlook 0
Commodore Accessing mail from multiple devices Using Outlook 1
S Programmatically accessing Outlook Calendar data Using Outlook 1
E Accessing User Defined Fields in BCM Database part 2 BCM (Business Contact Manager) 0
E [SOLVED] Accessing User Defined Fields in BCM Database part 1 BCM (Business Contact Manager) 9
K trying to sync my samsung galaxy to my outlook 2010 calender. it says execution privilege prevents me from accessing outlook Using Outlook 1
P time delay between accessing Outlook file folders, up 20+ second delay Using Outlook 1
S Accessing source information Using Outlook 1
J After Window update of 12/15/2010, outlook 2007 gives error (0x800CCC18) when accessing gmail using Using Outlook 6
S Outlook 2010 freezes and not responding when accessing, moving or deleting files Using Outlook 2
N Problems accessing network files via OWA Using Outlook 5
J Problems accessing console of Exchange 2010 on Windows Server 2008 R2 Please help me Exchange Server Administration 4
R Accessing folder 'Other Contacts' Outlook VBA and Custom Forms 1
E Accessing a Form Region from an Inspector Outlook VBA and Custom Forms 3
E Accessing a Form Region from an Inspector Outlook VBA and Custom Forms 3
D Accessing Global Address List details with VBA Outlook VBA and Custom Forms 1
H Accessing a control on a frame in Outlook with VBScript Outlook VBA and Custom Forms 1
K Programmatically accessing Outlook properties Outlook VBA and Custom Forms 3
K assistant accessing from her home computer BCM (Business Contact Manager) 2
J Outlook closes when accessing History in BCM BCM (Business Contact Manager) 4
B Accessing Outlook 2003 Signature Programmatically using C# Outlook VBA and Custom Forms 6
L Outlook Forms-Accessing Outlook VBA and Custom Forms 1
C Accessing _RecipientControl1 (Assigned To) Outlook VBA and Custom Forms 2
K Accessing contact's custom properties in a Outlook 2007 form region Outlook VBA and Custom Forms 1
V Outlook custom form - installing and accessing Outlook VBA and Custom Forms 1
A Daily hours of recurring/ multi-day appts, & accessing mult calend Outlook VBA and Custom Forms 2
R New users creating get page cannot be displayed when accessing OWA Exchange Server Administration 16
B Can I create a local PST file for SPAM on a drive that is usually disconnected? Using Outlook 3
P Outlook pst file is too huge with POP3. How to save more space? Using Outlook 4
K Disabling import/export button to restrict PST creation Using Outlook 3
K Export Folder to PST Outlook VBA and Custom Forms 2
I Outlook 365 - import/attach PST file that used POP3 Using Outlook.com accounts in Outlook 0
HarvMan Outlook 365 PST Report Using Outlook 1
P PST file is getting huge under POP 3 Using Outlook 2
M Export-Import .pst file problems Using Outlook 2
L Cannot open PST file for first session each day Using Outlook 6
David in Mississippi New (Feb 2020) install of Outlook 365 - Cannot specify PST for different accounts Using Outlook 0
GregS Outlook 2016 OST thinks it is PST? Using Outlook 1

Similar threads

Top