AddStore Method

Microsoft Outlook Visual Basic

AddStore Method

       

Adds a personal folder (.pst) file to the current profile.

expression.AddStore(Store)

expression   Required. An expression that returns a NameSpace object.

Store   Required Variant. The path of the .pst file to be added to the profile. If the .pst file does not exist, Microsoft Outlook creates it.

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:\" & 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:\" & myNS.CurrentUser & ".pst"