Using C# to create a user-defined field?

M

Mikael

Hi!


I am coding a solution that has a function to sync it's database with
Outlook. I use a User-Defined Field to keep track of "my" items and it works
great. BUT - I can not find a way to add the user-defined field to the
folder programmatically. If an app is to be distributet widely I can't ask
my users to do this by hand.

I have noticed that som apps (like Skype) has added user-defined fields
automatically, so there has to be a way - do you know or could you point me
in the right direction? I'm coding in C# and Visual Studio 2005.

Regards
Mikael
Sweden

(I was unsure if this should be published in Interop or Program_AddIns)
 
K

Ken Slovak - [MVP - Outlook]

Answered in Interop, although this is a better group for a question like
that.
 
J

j

If u want add fields to folder, u should create mailItem fill it with
properties and move to folder, that's all.
 
S

Sue Mosher [MVP-Outlook]

If u want add fields to folder, u should create mailItem fill it with
properties and move to folder, that's all.

That would be totally ineffective. Moving an item to a folder has no effect whatsoever on the fields defined in that folder.

To define a field in a folder in versions before Outlook 2007, use the MAPIFolder.Items.Add method to create a new item in the folder (a post item if it's a mail/post folder). Then use the item's UserProperties.Add method to create the property on the item, setting the third parameter to True. Finally, delete this new item, which is no longer needed.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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