简体   繁体   English

如何在使用DocumentItem时在Outlook中添加自定义列

[英]How to add custom column in outlook while using DocumentItem

I am developing VSTO addin using C# . 我正在使用C#开发VSTO插件。

在此处输入图片说明

Here, I have drag one file from my PC to outlook folder. 在这里,我已将一个文件从PC拖动到Outlook文件夹。 It displays in outlook as show in picture. 它在Outlook中显示为图片中所示。

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 . 列名是ABCDEFGHI

I want to update the value of ABCD.pdf file property. 我想更新ABCD.pdf文件属性的值。

As per outlook ABCD.pdf is a DocumentItem . 根据Outlook ABCD.pdfDocumentItem 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: 如果您查看MSDN中的UserProperties.Add方法描述,则可以看到以下描述:

You cannot add custom properties to Office document items such as Word, Excel, or PowerPoint files. 您不能将自定义属性添加到Office文档项目(如Word,Excel或PowerPoint文件)。 You will receive an error when you try to programmatically add a user-defined field to a DocumentItem object. 当您尝试以编程方式将用户定义的字段添加到DocumentItem对象时,您将收到一个错误。

Instead, I'd recommend creating any Outlook item and attaching a document to it. 相反,我建议创建任何Outlook项目并将文档附加到该项目。 Following that way you will be able to customize the View by adding user properties as you need. 通过这种方式,您将能够通过根据需要添加用户属性来自定义视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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