AddStore Method Example

This Microsoft Visual Basic/Visual Basic for Applications example adds a new personal folder (.pst) file to the user’s profile.

Dim myOlApp As New Outlook.Application
Dim myNS As Outlook.NameSpace
Set myNS = myOlApp.GetNamespace("MAPI")
myNS.AddStore "c:\my documents\" & myNS.CurrentUser & ".pst"

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myNS = Application.GetNamespace("MAPI")
myNS.AddStore "c:\my documents\" & myNS.CurrentUser & ".pst"