Setting custom properties to an outlook folder

M

Michael Jennings

I'm new to the Outlook 2007 object model. I want to create and set some
custom properties to my outlook folders. eg I want to set a property like
'source url', which is of string type, that will enable me to find out
programmatically which folder belongs to which url. I think PropertyAccessor
has something to do with it. I tried the following code:-

string prop =
"http://schemas.microsoft.com/mapi/string/{5ae18700-583b-4e33-b0b8-bbcffc9ebd24}/siteUrl";
Folder folder = (Folder)tasksFolder.Folders.Add(folderName,
OlDefaultFolders.olFolderTasks);
folder.PropertyAccessor.SetProperty(prop, "http://www.microsoft.com");


It throws an exception - The property
"http://schemas.microsoft.com/mapi/string/{5ae18700-583b-4e33-b0b8-bbcffc9ebd24}/siteUrl"
does not support this operation.

Please help !!
 
D

Dmitry Streblechenko

Exchage folders do not support named properties (messages do of course).
The standard way of handling a situation like this is to create an
associated (hidden) message with a custom class in that folder.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
G

Guest

Can you please show me the code to create the hidden message with a custom
class.

-Thanks
 
D

Dmitry Streblechenko

IMAPIFolder::CreateMessage(..., MAPI_ASSOCIATED, ...)
Then set the PR_MESSAGE_CLASS to your custom value.
When you need to open your config message, retrieve the associated contents
table (IMAPIFolder::GetContentsTable(MAPI_ASSOCIATED, ...)), then use
HrQueryAllRows specifying PR_ENTRYID as the column and a restriction on
PR_MESSAGE_CLASS equal to your custom value. If the message cannot be found,
create a new one using IMAPIFolder::CreateMessage().

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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