我正在使用以下代码创建一个新的pst文件。但是,pst文件是在Outlook中使用默认名称“ Outlook Data File”创建的。我找不到任何设置新pst文件名称的选项。
Set objNS = objOutlook.GetNamespace("MAPI")
objNS.AddStoreEx "C:\Users\pitarr\Documents\Outlook Files\f23.pst",2
答案 0 :(得分:0)
尝试调用添加的数据存储返回的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
顺便说一句,以上两个示例都未经测试,可能取决于所使用的编码。
希望这会有所帮助。