Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA for Export pst (XP)

    <img src=/S/angel.gif border=0 alt=angel width=15 height=21>

    I have looked through the forum here and have found related topic but no actual solution.

    Can you automate a straightforward export .pst file given the folder you want to export? I want to cycle through each folder and export them.
    Thanks,

    pmatz

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBA for Export pst (XP)

    Try something like this. You can add error handling etc.

    'Variables
    Dim nsp As NameSpace
    Dim fldSource As MAPIFolder
    Dim fldTarget As MAPIFolder
    'Create namespace reference
    Set nsp = GetNamespace("MAPI")
    'Reference to source folder - modify as needed
    Set fldSource = nsp.GetDefaultFolder(olFolderSentMail)
    'Create .pst file - modify path and name as needed
    nsp.AddStore "C:MyExport.pst"
    'Reference to new folder
    Set fldTarget = nsp.Folders.GetLast
    'Copy source folder with all its subfolders
    fldSource.CopyTo fldTarget
    'Detach .pst file (does not delete it from disk!)
    nsp.RemoveStore fldTarget
    ' Clean up
    Set fldTarget = Nothing
    Set fldSource = Nothing
    Set nsp = Nothing

  3. #3
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA for Export pst (XP)

    thanks for the code Hans, i have modified it to cycle through folders and add to the personal folder. the .addStore is a cool method.

    have a good weekend [img]/forums/images/smilies/smile.gif[/img]
    Thanks,

    pmatz

Posting Permissions

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