Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Apr 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create a PST object in Outlook (Outlook 2000)

    I'm trying to create a "manual archive" facility for people who can't create and save their own PST files in Outlook. I am using an AddStore command to create a new PST file but, I can't figure out how to access the PST file once it's created. I can't find an object for it,.

    Can anyone help ?

    Many thanks

    GB
    <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Create a PST object in Outlook (Outlook 2000)

    The MAPIFolder objects in the NameSpace.Folders collection are your open PST files. But when you create a new PST using AddStore, you don't have a handy way to identify it in the collection. The following works in a quick test, but I don't know how reliable it will turn out to be in production:

    <pre>Sub NewPSTTest()
    Dim ns As NameSpace, newPST As MAPIFolder
    'Create Outlook NameSpace
    Set ns = Application.GetNamespace("MAPI")
    'Add new PST file
    ns.AddStore "c:testingMyNewPST.pst"
    'Get a reference to the "last" PST in the ns.Folders collection
    Set newPST = ns.Folders.GetLast
    newPST.Name = "Test Archive " & newPST.Name
    'Check the View|Locals window...debug only!!
    Stop
    'Do your real stuff

    'Clean up objects
    Set newPST = Nothing
    Set ns = Nothing
    End Sub</pre>

    Hope this helps.

  3. #3
    Lounger
    Join Date
    Apr 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create a PST object in Outlook (Outlook 2000)

    Many thanks. It seems to work although a little bit flakey - it picks up the last created folder but a rename doesn't work. Should be fine with a bit of starch.

    Cheers

    GB
    <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •