当用户直接在会议室的日历中创建会议时,组织者字段被设置为会议室的名称(没有创建会议的用户)。 是否可以获取使用EWS 2010创建会议的用户的名称?
答案 0 :(得分:1)
如果您检查应显示创建者名称的发件人扩展属性(代表发送时将是邮箱名称),例如
Mailbox MeetingRoom = new Mailbox("room@domain.com");
FindItemsResults<Appointment> appts = service.FindAppointments(new FolderId(WellKnownFolderName.Calendar,MeetingRoom),new CalendarView(DateTime.Now,DateTime.Now.AddMonths(1),1000));
ExtendedPropertyDefinition PR_SENDER_EMAIL_ADDRESS_W = new ExtendedPropertyDefinition(0x0C1F,MapiPropertyType.String);
ExtendedPropertyDefinition PR_SENDER_ADDRTYPE_W = new ExtendedPropertyDefinition(0x0C1E,MapiPropertyType.String);
PropertySet psProps = new PropertySet();
psProps.Add(PR_SENDER_ADDRTYPE_W);
psProps.Add(PR_SENDER_EMAIL_ADDRESS_W);
if(appts.Items.Count > 0){
service.LoadPropertiesForItems(from Item item in appts select item,psProps);
foreach(Appointment apt in appts){
Object SenderAddressType = null;
Object SenderAddress = null;
if(apt.TryGetProperty(PR_SENDER_ADDRTYPE_W,out SenderAddressType)){
if(apt.TryGetProperty(PR_SENDER_EMAIL_ADDRESS_W,out SenderAddress)){
if(SenderAddressType.ToString() == "EX")
{
NameResolutionCollection nccol = service.ResolveName(SenderAddress.ToString(),ResolveNameSearchLocation.DirectoryOnly,true);
if(nccol.Count == 1){
Console.WriteLine(nccol[0].Mailbox.Address);
}
}
else
{
Console.WriteLine(SenderAddress);
}
}
}
}
}