我发现了如何将自定义分类添加到Outlook(使用本地部署的classification.xml和相关的策略注册表项)。这些自定义值显示在权限拆分按钮菜单中,使用UI我可以设置分类。然而,我需要做的是根据主动选择的分类值进行一些自定义操作。这是我的挑战。UI中设置的任何内容似乎都不会反映在Permissions或PermissionTemplateGuid属性中。有人能告诉我如何获得MailItem(更具体地说,当前正在编写的邮件)的活动分类吗
编辑:由于旧的工作代码通过检查命令栏按钮状态来解决问题,这在Outlook 2013中显然不再有效-如果你告诉我如何制作基于功能区的等效程序,我也愿意接受答案-因为不可能重新使用内置的PermissionRestrictMenu拆分按钮。
Office.CommandBarPopup permissionControl = mailItem.GetInspector.CommandBars.FindControl(Office.MsoControlType.msoControlPopup, AddinConfigurationManager.PermissionControlId, Type.Missing, Type.Missing)
as Office.CommandBarPopup;
Office.CommandBarButton restrictedDistributionButton = GetRestrictedDistributionControlIndex(permissionControl);
其中GetRestrictedDistributionControlIndex处理permissionControl.get_accChild
我最终明白了。我在PSETID_Common属性集下找到了一些命名的MAPI属性,即Classified、Classification、ClassificationDescription、ClassificationGuid和ClassificationKeep。为了从UI中检测分类集,我只得到名为proptag的classification的值。我发现这个标签可以使用下面的id名称空间访问:
"http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/85B6001F"
为了设置邮件项目的分类,我成功地按以下特定顺序设置了属性:classification、ClassificationDescription、ClassificationGuid、Classified和ClassificationKeep。
string PSETID_Common = "http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/"
Outlook.PropertyAccessor pa = mailItem.PropertyAccessor;
pa.SetProperty(PSETID_Common + "85B6001F", "short name"); // set short name
pa.SetProperty(PSETID_Common + "85B7001F", "description"); // set description
pa.SetProperty(PSETID_Common + "85B8001F", "00000000-0000-0000-0000-000000000000"); // set GUID
pa.SetProperty(PSETID_Common + "85B5000B", true); // Mark as Classified
pa.SetProperty(PSETID_Common + "85BA000B", true); // Keep classification