在 C# 中以编程方式检查所需与会者的姓名

Programmatically check names of required attendees in C#

我正在编写一个简单的 outlook 插件,我需要让所需的与会者参加约会。

为此,我使用以下代码:

...
Outlook.AppointmentItem appointment theCurrentAppointment = 
                                Inspector.CurrentItem as Outlook.AppointmentItem;
String attendees = appointment.RequiredAttendees;
/// attendees is empty if names are not checked
/// otherwise has the correct value

此代码只有在我使用检查名称功能 (CTRL+K) 时才能正常工作,否则它 returns 一个空字符串。

是否可以在 C# 中以编程方式检查所需参加者(预约)的姓名?

抱歉,C# 不是我的编程语言,我不知道我是否使用了正确的术语。


如何重现错误:

如何解决问题(手动,而不是以编程方式)

我需要在保存约会之前知道 RequiredAttendees 的值。所以我不能保存它然后检查 RequiredAttendees 的值。

在查看与会者列表之前,我认为您首先需要通过以下方式保存约会项目:

AppointmentItem.Save();

参考:https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._appointmentitem.save.aspx

保存后,再次获取该约会对象和运行获取所需参加者所需的代码(如下所示)。

字符串变量 attendees 将包含一个 semi-colon 分隔字符串,其中包含每个与会者的姓名。

从那里,您可以通过以下方式解析它:

字符串[]名称=attendees.Split(';');

这将 return 与会者姓名数组。

有关详细信息,请参阅 _AppointmentItem.RequiredAttendees 属性。

不使用 RequiredAttendees 属性,而是遍历 Recipients 集合中的所有收件人并检查 Recipient.Type == olTo(必需)。