我有一个问题:如果约会主体是由Outlook365客户端创建的,则无法获取约会主体。 当我运行代码时,将接收除正文以外的所有属性值。
经过一番搜索,我发现如果Outlook365进行了约会,则没有收到约会机构。 请帮忙!
代码:
public static List<Appointment> SetupConnection()
{
ServicePointManager.ServerCertificateValidationCallback = CallbackMethods.CertificateValidationCallBack;
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials("Someuser@somedomain.com", "SomePassword");
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
Folder calendarFolder = GetCalendarFolder(service, @"\");
return GetMeetings(calendarFolder, service);
}
public static List<Appointment> GetMeetings(Folder calendarFolder, ExchangeService service)
{
if (calendarFolder == null)
{
return null;
}
SearchFilter.SearchFilterCollection filters = new SearchFilter.SearchFilterCollection(LogicalOperator.And)
{
new SearchFilter.IsGreaterThan(AppointmentSchema.Start, DateTime.Today)
};
List<Appointment> meetings = new List<Appointment>();
const Int32 pageSize = 30;
ItemView itemView = new ItemView(pageSize);
PropertySet propertySet = new PropertySet(BasePropertySet.IdOnly);
itemView.PropertySet = propertySet;
FindItemsResults<Item> findResults = null;
do
{
findResults = calendarFolder.FindItems(filters, itemView);
itemView.Offset += pageSize;
meetings.AddRange(findResults.Cast<Appointment>());
} while (findResults.MoreAvailable);
PropertySet propertySet1 = new PropertySet(BasePropertySet.IdOnly);
propertySet1.Add(ItemSchema.Body);
propertySet1.Add(ItemSchema.Subject);
propertySet1.Add(AppointmentSchema.Organizer);
propertySet1.Add(AppointmentSchema.Start);
propertySet1.Add(AppointmentSchema.End);
propertySet1.Add(AppointmentSchema.Duration);
propertySet1.Add(AppointmentSchema.AppointmentType);
propertySet1.Add(AppointmentSchema.ConferenceType);
propertySet1.Add(AppointmentSchema.IsOnlineMeeting);
propertySet1.Add(AppointmentSchema.IsMeeting);
propertySet1.Add(AppointmentSchema.IsRecurring);
propertySet1.Add(AppointmentSchema.HasAttachments);
propertySet1.Add(AppointmentSchema.RequiredAttendees);
propertySet1.Add(AppointmentSchema.Resources);
propertySet1.Add(AppointmentSchema.InternetMessageHeaders);
propertySet1.RequestedBodyType = Microsoft.Exchange.WebServices.Data.BodyType.Text;
service.LoadPropertiesForItems(meetings, propertySet1);
return meetings;
}
}
答案 0 :(得分:0)
您的代码仅返回IdOnly
尝试将BasePropertySet.IdOnly
更改为BasePropertySet.FirstClassProperties