简体   繁体   中英

How to add custom column in outlook while using DocumentItem

I am developing VSTO addin using C# .

在此处输入图片说明

Here, I have drag one file from my PC to outlook folder. It displays in outlook as show in picture.

Now I want to add one column in that folder. I have done some code to add custom column in folder. It will display in picture. Column name is ABCDEFGHI .

I want to update the value of ABCD.pdf file property.

As per outlook ABCD.pdf is a DocumentItem . I want to add my custom property for that file, to display in view.

This is my sample code.

 UserProperties objUserProperties  = objItem.UserProperties;
 UserProperty objUserProperty = objUserProperties.Add("ABCDEFGHI", OlUserPropertyType.olText);
 objt.Value = "YYYY";

This will give me an error .

Error: 在此处输入图片说明

If you take a look at the UserProperties.Add method description in MSDN you can see the following description:

You cannot add custom properties to Office document items such as Word, Excel, or PowerPoint files. You will receive an error when you try to programmatically add a user-defined field to a DocumentItem object.

Instead, I'd recommend creating any Outlook item and attaching a document to it. Following that way you will be able to customize the View by adding user properties as you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM