Change a .pst display name by code

R

Rolando Tonin

I’m developing an Outlook2007
AddIn in C# with Visual Studio 2008 and VSTO 3.0.
I create an .pst file with this code:

this.DefaultNameSpace.AddStoreEx(@"C:\DATI\IDROESSE\IDROESSE.PST",
OlStoreType.olStoreDefault);

Now I want to change the default displayName "Personal Folder" (Italian
speak: "Cartelle Personali") with my company name. First I get the object
store:

private Store CheckStore(string storePath)
{
foreach (Store obj in this.DefaultNameSpace.Stores)
{
if (obj.FilePath == storePath)
return obj;
}
return null;
}
and, conseguently, add this code after create .pst file:

this.DefaultNameSpace.AddStoreEx(@"C:\DATI\IDROESSE\IDROESSE.PST",
OlStoreType.olStoreDefault);
Store sto = this.CheckStore(@"C:\DATI\IDROESSE\IDROESSE.PST");
if (sto != null)

sto.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3001001E", "Idroesse");

the call to SetProperty generate an UnauthorizedAccessException. The
permission on the path C:\DATI\IDROESSE\ is full control for each Domain
Users. Why I get an Exception? How can I resolve the problem?
thanks in advance
Rolando Tonin
 
K

Ken Slovak - [MVP - Outlook]

PR_DISPLAY_NAME is read only for a store, it's set by the store provider.
You would have to write your own store provider in Extended MAPI to be able
to set that property as desired.
 
R

Rolando Tonin

thanks, where i found documentation about write in c# a store provider in
Extended MAPI?
Rolando Tonin
 
K

Ken Slovak - [MVP - Outlook]

Extended MAPI is programmed only in unmanaged C++ or Delphi, you can't
program it in C# or other managed code. Learning enough Extended MAPI to
actually write a store provider is a long process and has a very steep
learning curve. MAPI is not an easy interface to learn well enough to
actually write a store provider.
 

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