More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

Login

login
password
Remember me

You will need to register and log in if you want to download the source code for the Microsoft Outlook Programming book. The forums and code sharing areas are open to both registered and non-registered visitors.

share code 02-Sep-2010 22:30

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

 

Code level: intermediate    Code area: Basic Outlook Printer Friendly Version
Title: Add new PST file (revised)
Description: This revised version enhances an earlier sample to refresh the folder list to show the new store's display name and double-check the new store's EntryID against those of existing stores to identify with certainty which one is the new store.
Date: 11-Jul-2005  01:32
Code level: intermediate
Code area: Basic Outlook
Posted by: Sue Mosher
Body:
All 18comments
Page [ 1 2 Next >>  
  11-Jul-2005  08:34   
Note that if the .pst file named strFileName does not already exist, Outlook will create it.

To demonstrate this function, you can use this test procedure:

Sub TestSetNewStore2()
    Dim newStore As Outlook.MAPIFolder
    On Error Resume Next
    
    Set newStore = SetNewStore2("C:\MyNewStore.pst", "My New Store Folders")
    Debug.Print newStore.Name
    Debug.Print newStore.Folders("Deleted Items").Items.Count
    
    Set newStore = Nothing
End Sub
  07-Jun-2006  08:05   
Thanks Sue
  04-Jul-2006  20:06   
Hi Sue thanks for you help, these are the samples i have been working with...
but i've started from clean again and just used your samples... the problem im, having is with the SetNewStore2

When it gets to:
   ' give the newly added PST store a display name
   ' This should be unique to make it easier to distinguish
   ' it from other stores.
   objFolder.Name = strDisplayName

objfolder is not longer a vlaid object.. and i cant see why that is, its unchanged from your sample and i think it should always be a MAPIFOLDER object. otherwise it will never retrun the FolderObject from the function.

Any ideas?


 
  04-Jul-2006  21:21   
It seems to die in this part:

        For i = 1 To (objNS.Folders.Count - 1)
            Set objFolder = objNS.Folders.GetPrevious
            If Not FolderEntryIDIsInArray(objFolder, arr()) Then
                Exit For
            End If
        Next

the first runthrough is fine but after that "Set objFolder = objNS.Folders.GetPrevious"
objfolder is no longer a valid object.

 
  07-Jul-2006  07:49   
I would try commenting out the On Error Resume Next statement and step through the code. You can also throw in a MsgBox objFolder.Name statement to help you see which store you're working with an any given point.
  08-Sep-2006  03:38   
Hi All,

The Application is not named properly if you are using this code from outside of Outlook, such as calling from MS Access

Try ths instead

Set objOL = Outlook.Application ' intrinsic Application object in Outlook VBA
Set objNS = objOL.GetNamespace("MAPI")
  08-Sep-2006  06:19   
James, you need to use CreateObject or GetObject or New to instantiate the Outlook.Application object. See http://www.outlookcode.com/codedetail.aspx?id=83
  27-Oct-2006  11:01   
Ok now is it possible to view a list of pst stores that already have been added to outlook (through file >open > .pst) and to put these into a combo box by the name they have in the outlook folderlist. Then is is possible to retrieve the email address of the selected pst file in the combo?
  27-Oct-2006  12:21   
deekay, you can use the Namespace.Folders collection to iterate all the stores in the current Outlook profile.

A PST file itself has no email address.
  28-Oct-2006  05:14   
Ok thanks. So If I can get the pst file in my folders list which is being used on another users computer is there anyway i can get the email address that they have setup on their computer or is that on setup on their local copy of outlook?
Page [ 1 2 Next >>  
Post your comment



name        email