Reputation: 2515
I am developing a small Outlook add-in which will fetch all information about selected meeting and push this information to our in-house portal. Implementation is complete except RequiredAttendees part. Not sure why, but Interop.Outlook.AppointmentItem object is only returning full names (as string) of the attendees. I am more interested in their email address of attendees. Here is my code snippet to replicate the issue:
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);
}
I can see RequiredAttendees property is defined as string in Microsoft.Office.Interop.Outlook._AppointmentItem interface.
//
// 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; }
I will greatly appreciate if someone can help me to resolve this issue or provide some around to get attendees email addresses.
Thanks.
Upvotes: 1
Views: 2037
Reputation: 8130
Something like this (not tested):
// 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;
}
Upvotes: 4