使用自定义名称创建 pst 文件
Create pst file with custom name
我正在使用以下代码创建一个新的 pst 文件。但是 pst 文件是使用 Outlook 中的默认名称 "Outlook Data File" 创建的。我找不到任何设置新 pst 文件名称的选项。
Set objNS = objOutlook.GetNamespace("MAPI")
objNS.AddStoreEx "C:\Users\pitarr\Documents\Outlook Files\f23.pst",2
尝试调用您添加的数据存储返回的 PropertyAccessor 对象的 SetProperty 方法。例如:
Const PR_DISPLAY_NAME = "http://schemas.microsoft.com/mapi/proptag/0x3001001F"
Dim oStore, oPA
For Each oStore in objNS.Stores
If oStore.FilePath = "C:\Users\pitarr\Documents\Outlook Files\f23.pst" Then
Set oPA = oStore.PropertyAccessor
oPA.SetProperty PR_DISPLAY_NAME, "SomeNewName"
End If
Next
否则,看看重命名商店的根文件夹是否足够,如Lankymart建议:
Dim oStore, oFolder
For Each oStore in objNS.Stores
If oStore.FilePath = "C:\Users\pitarr\Documents\Outlook Files\f23.pst" Then
Set oFolder = oStore.GetRootFolder()
oFolder.Name = "SomeNewName"
End If
Next
顺便说一句,以上两个示例都未经测试,可能取决于所使用的编码。
希望对您有所帮助。
我正在使用以下代码创建一个新的 pst 文件。但是 pst 文件是使用 Outlook 中的默认名称 "Outlook Data File" 创建的。我找不到任何设置新 pst 文件名称的选项。
Set objNS = objOutlook.GetNamespace("MAPI")
objNS.AddStoreEx "C:\Users\pitarr\Documents\Outlook Files\f23.pst",2
尝试调用您添加的数据存储返回的 PropertyAccessor 对象的 SetProperty 方法。例如:
Const PR_DISPLAY_NAME = "http://schemas.microsoft.com/mapi/proptag/0x3001001F"
Dim oStore, oPA
For Each oStore in objNS.Stores
If oStore.FilePath = "C:\Users\pitarr\Documents\Outlook Files\f23.pst" Then
Set oPA = oStore.PropertyAccessor
oPA.SetProperty PR_DISPLAY_NAME, "SomeNewName"
End If
Next
否则,看看重命名商店的根文件夹是否足够,如Lankymart建议:
Dim oStore, oFolder
For Each oStore in objNS.Stores
If oStore.FilePath = "C:\Users\pitarr\Documents\Outlook Files\f23.pst" Then
Set oFolder = oStore.GetRootFolder()
oFolder.Name = "SomeNewName"
End If
Next
顺便说一句,以上两个示例都未经测试,可能取决于所使用的编码。
希望对您有所帮助。