public static AddressEntry GetEventOrganizerOrNull (AppointmentItem source, IEntityMappingLogger logger, ILog generalLogger, int outlookMajorVersion)
{
try
{
if (outlookMajorVersion < 14)
{
// Microsoft recommends this way for Outlook 2007. May still work with Outlook 2010+
using (var propertyAccessor = GenericComObjectWrapper.Create (source.PropertyAccessor))
{
string organizerEntryID = propertyAccessor.Inner.BinaryToString (propertyAccessor.Inner.GetProperty(PR_SENT_REPRESENTING_ENTRYID));
return Globals.ThisAddIn.Application.Session.GetAddressEntryFromID (organizerEntryID);
}
}
else
{
// NB this works with Outlook 2010 but crashes with Outlook 2007
return source.GetOrganizer();
}
}
catch (COMException ex)
{
generalLogger.Warn ("Can't get organizer of appointment", ex);
logger.LogMappingWarning ("Can't get organizer of appointment", ex);
return null;
}
}