交换 Web 服务从可用性列表中获取会议 ID



我正在创建这样的约会

Appointment appointment = new Appointment(service);
appointment.Subject = m.Subject;
appointment.Start = m.StartTime;
appointment.End = m.EndTime;
appointment.StartTimeZone = TimeZoneInfo.Utc;
appointment.EndTimeZone = TimeZoneInfo.Utc;
....
appointment.Save(folder, SendInvitationsMode.SendToNone);

然后我可以检索CalIdVal

我的系统会列出用户的约会。我得到这个使用

GetUserAvailabilityResults results = service.GetUserAvailability(attendees, tw, AvailabilityData.FreeBusyAndSuggestions);

我想过滤掉上面创建的约会。 但是此列表不包含任何ID,因此我看不出如何。

任何建议表示赞赏

您需要将GetUserAvailability中的FreeBusyViewType设置为详细 https://learn.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.freebusyviewtype?view=exchange-ews-api 然后您应该返回约会的HexEntryID列表,然后您可以将其转换为EWSId,以便您可以绑定/过滤例如

DateTime StartTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 0:00"));
DateTime EndTime = StartTime.AddDays(1);
TimeWindow tmTimeWindow = new TimeWindow(StartTime, EndTime);
AvailabilityOptions aoOptions = new AvailabilityOptions();
aoOptions.RequestedFreeBusyView = Microsoft.Exchange.WebServices.Data.FreeBusyViewType.DetailedMerged;
aoOptions.MeetingDuration = 30;
List<AttendeeInfo> atAttendeeList = new List<AttendeeInfo>();
atAttendeeList.Add(new AttendeeInfo("user@domain.com"));
GetUserAvailabilityResults avResponse = service.GetUserAvailability(atAttendeeList, tmTimeWindow, AvailabilityData.FreeBusy, aoOptions);
Int32 atnCnt = 0;
foreach (AttendeeAvailability avail in avResponse.AttendeesAvailability)
{
Console.WriteLine(atAttendeeList[atnCnt].SmtpAddress);
Int32 mc = 0;
var merged = avail.MergedFreeBusyStatus;
while (StartTime < EndTime)
{
Console.WriteLine(StartTime.ToString() + " " + merged[mc]);
mc++;
StartTime = StartTime.AddMinutes(30);
}
foreach (Microsoft.Exchange.WebServices.Data.CalendarEvent calendarItem in avail.CalendarEvents)
{
Console.WriteLine("Free/busy status: " + calendarItem.FreeBusyStatus);
Console.WriteLine("Start time: " + calendarItem.StartTime);
Console.WriteLine("End time: " + calendarItem.EndTime);
var convertedId = (AlternateId)service.ConvertId(new AlternateId(IdFormat.HexEntryId, calendarItem.Details.StoreId, "someemail@domain.com"), IdFormat.EwsId);
var apt = Appointment.Bind(service, new ItemId(convertedId.UniqueId));
}
atnCnt++;
}