我正在开发一个小型Outlook加载项,它将获取有关所选会议的所有信息,并将此信息推送到我们的内部门户网站。除RequiredAttendees部分外,实现完成。不确定原因,但 Interop.Outlook.AppointmentItem 对象只返回与会者的全名(作为字符串)。我对他们的与会者电子邮件地址更感兴趣。这是我的代码片段来复制问题:
try
{
AppointmentItem appointment = null;
for (int i = 1; i < Globals.ThisAddIn.Application.ActiveExplorer().Selection.Count + 1; i++)
{
Object currentSelected = Globals.ThisAddIn.Application.ActiveExplorer().Selection[i];
if (currentSelected is AppointmentItem)
{
appointment = currentSelected as AppointmentItem;
}
}
// I am only getting attendees full name here
string requiredAttendees = appointment.RequiredAttendees;
}
catch (System.Exception ex)
{
LogException(ex);
}
我可以看到RequiredAttendees属性在 Microsoft.Office.Interop.Outlook._AppointmentItem 界面中被定义为字符串。
//
// Summary:
// Returns a semicolon-delimited String (string in C#) of required attendee
// names for the meeting appointment. Read/write.
[DispId(3588)]
string RequiredAttendees { get; set; }
如果有人可以帮助我解决此问题或提供一些参与者电子邮件地址,我将不胜感激。
感谢。
答案 0 :(得分:3)
像这样(未经测试):
// Recipients are not zero indexed, start with one
for (int i = 1; i < appointment.Recipients.Count - 1; i++)
{
string email = GetEmailAddressOfAttendee(appointment.Recipients[i]);
}
// Returns the SMTP email address of an attendee. NULL if not found.
function GetEmailAddressOfAttendee(Recipient TheRecipient)
{
// See http://msdn.microsoft.com/en-us/library/cc513843%28v=office.12%29.aspx#AddressBooksAndRecipients_TheRecipientsCollection
// for more info
string PROPERTY_TAG_SMTP_ADDRESS = @"http://schemas.microsoft.com/mapi/proptag/0x39FE001E";
if (TheRecipient.Type == (int)Outlook.OlMailRecipientType.olTo)
{
PropertyAccessor pa = TheRecipient.PropertyAccessor;
return pa.GetProperty(PROPERTY_TAG_SMTP_ADDRESS);
}
return null;
}