1

我正在开发一个小型 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; }

如果有人可以帮助我解决此问题或提供一些帮助以获取与会者的电子邮件地址,我将不胜感激。

谢谢。

4

1 回答 1

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;
}
于 2013-01-16T05:04:19.697 回答