2013-01-09 135 views
1

我正在開發一個小型Outlook加載項,它將獲取有關所選會議的所有信息並將此信息推送到我們的內部門戶。除了RequiredAttendees部分,實現是完整的。不知道爲什麼,但Interop.Outlook.AppointmentItem對象僅返回與會者的全名(字符串)。我對他們的參與者的電子郵件地址更感興趣。這裏是我的代碼片段複製問題:Outlook加載項:獲取與會者選定會議的電子郵件地址

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; } 

我將不勝感激,如果有人可以幫助我解決這個問題或提供一些各地去參加者的電子郵件地址。

謝謝。

回答

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; 
} 
+0

如果我們刪除if條件'如果(TheRecipient.Type ==(INT)Outlook.OlMailRecipientType.olTo)',那麼我們就可以得到電子郵件的地址可選參加者也是如此。 – digitguy

相關問題