2013-01-09 1 views
1

Je suis en train de développer un petit add-in Outlook qui récupérera toutes les informations sur la réunion sélectionnée et transmettra cette information à notre portail interne. La mise en œuvre est terminée sauf la partie RequiredAttendees. Vous ne savez pas pourquoi, mais l'objet Interop.Outlook.AppointmentItem renvoie uniquement les noms complets (en tant que chaîne) des participants. Je suis plus intéressé par leur adresse e-mail des participants. Voici mon extrait de code pour reproduire le problème:Add-in Outlook: Récupérer l'adresse e-mail des participants de la réunion sélectionnée

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

Je peux voir propriété RequiredAttendees est définie comme chaîne dans l'interface 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; } 

J'apprécierais si quelqu'un peut me aider à résoudre ce problème ou de fournir des tour pour obtenir les adresses e-mail Participants.

Merci.

Répondre

3

Quelque chose comme ça (non testé):

// 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

Si on enlève la condition if 'if (TheRecipient.Type == (int) Outlook.OlMailRecipientType.olTo)', nous pouvons obtenir l'adresse e-mail de participants optionnels aussi. – digitguy

Questions connexes