AddStoreEx Method

Microsoft Outlook Visual Basic

Show All Show All

AddStoreEx Method

Adds a Personal Folders file (.pst) in the specified format to the current profile.

expression.AddStoreEx(Store, Type)

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.

Type    Required OlStoreType constant. The format in which the data file should be created.

OlStoreType can one of the following constants:
  • olStoreDefault (1)
  • olStoreUnicode (2)
  • olStoreANSI (3)

Remarks

Use the olStoreUnicode constant to add a new .pst file that has greater storage capacity for items and folders and supports multilingual Unicode data, to the user's profile. The olStoreANSI constant allows you to create .pst files that do not provide full support for multilingual Unicode data, but are compatible with earlier versions of Outlook. The olStoreDefault constant helps you create a .pst file in the default format that is compatible with the mailbox mode in which Outlook runs on the Microsoft Exchange Server.

Example

This Microsoft Visual Basic/Visual Basic for Applications (VBA) example adds a new Personal Folders (.pst) file that has greater storage capacity for items and folders and supports Unicode to the user’s profile.

    Sub CreateUnicodePST()
    Dim myOlApp As New Outlook.Application
    Dim myNameSpace As Outlook.NameSpace
    Set myNameSpace = myOlApp.GetNamespace("MAPI")
    myNameSpace.AddStoreEx "c:\" & myNameSpace.CurrentUser & ".pst",olStoreUnicode
End Sub
  

If you use Microsoft Visual Basic Scripting Edition (VBScript) in an Outlook form, you do not create the Application object. This example shows how to perform the same task using VBScript.

Sub CreateUnicodePST()
	Set myNS = Application.GetNamespace("MAPI")
	myNS.AddStoreEx "c:\" & myNS.CurrentUser & ".pst", 2
End Sub