Opening PST-File with AddStoreEx removes Display Name

T

tobias.vilen

Hi,

I am adding a PST-file with the following code;

Dim PSTFileName, Application, objName, PSTFile, fso
pstFileName = "%s"

Set Application = CreateObject("Outlook.Application")
Set objName = Application.GetNamespace("MAPI")
Set fso = CreateObject("Scripting.FileSystemObject")
Set PSTFile = fso.GetFile(pstFileName)

' Second argument is Type (1=Default,2=Unicode,3=Ansi)
objName.AddStoreEx PSTFile, %d

if Err <> 0 Then
WScript.StdOut.WriteLine "Success=F"
WScript.StdErr.WriteLine "ErrorNumber=" & Err.Number
WScript.StdErr.WriteLine "ErrorDescription=" & Err.Description
WScript.StdErr.WriteLine "ErrorSource=" & Err.Source
WScript.Quit 1
else
WScript.StdOut.WriteLine "Success=T"
WScript.Quit 0
End if

%s is the file system path to the file.
If I previously have defined a Display Name for my PST-file in outlook
it seems as that display name is replaced with the default "Personal
Folders" when viewing the file opened with the above code in Outlook.
Am I doing something wrong somewhere, or is this the default behaviour
for AddStoreEx?

Best Regards
Tobias
 
M

Michael Bauer [MVP - Outlook]

I can't repro that. My guess: AddStoreEx' first argument is a Variant and
expects the file name, but you pass a Scripting File object to it.

Even if that's not the error in this case, due to this Variant issue you
always should explicitly write the property name instead of relying on any
defaults.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - The most effective way to assign Outlook categories:
http://www.shareit.com/product.html?productid=300120654&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)

Am 30 Mar 2007 02:09:01 -0700 schrieb (e-mail address removed):
 
T

tobias.vilen

I can't repro that. My guess: AddStoreEx' first argument is a Variant and
expects the file name, but you pass a Scripting File object to it.

Even if that's not the error in this case, due to this Variant issue you
always should explicitly write the property name instead of relying on any
defaults.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - The most effective way to assign Outlook categories:
http://www.shareit.com/product.html?productid=300120654&languageid=1
(German:http://www.VBOffice.net/product.html?pub=6)

Am 30 Mar 2007 02:09:01 -0700 schrieb (e-mail address removed):











- Visa citerad text -

Thanks for your reply,
I've reproduced it on a few XP SP2 clients running O2K3, pretty
standard installations with these instructions;
1. Create a new PST file
2. Accept the defaults, set the display name to something other than
the default, for example "Test folder 1"
3. Right click the Personal Folder in the folder pane, choose "Close"
4. Map the PST using the above script
5. Open outlook and check what the displayname is.

The above yielded "Personal Folders" on all installations i've tried
with.
 
T

tobias.vilen

Did you try my suggestion to explicitly pass the name instead of an object
to the function?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - The most effective way to assign Outlook categories:
http://www.shareit.com/product.html?productid=300120654&languageid=1
(German:http://www.VBOffice.net/product.html?pub=6)

Am 2 Apr 2007 01:33:03 -0700 schrieb (e-mail address removed):








- Visa citerad text -

I were not able to test previously, and should have awaited to send a
reply until I had, since your suggestion solved my issue :)
I get the correct display name using the below snippet (pstFileName is
the file system path to my PST file)

Set Application = CreateObject("Outlook.Application")
Set objName = Application.GetNamespace("MAPI")
' Second argument is Type (1=Default,2=Unicode,3=Ansi)
objName.AddStoreEx pstFileName, 3

Thanks for your assistance!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top