3

我正在使用 EWS 托管 API 2.0。我正在使用日历部分,您可以在其中预订约会,如下所示:

Appointment appointment = new Appointment(service);

//Set properties on the appointment.
appointment.Subject = "Dentist Appointment";
appointment.Body = "The appointment is with Dr. Smith.";
appointment.Start = new DateTime(2009, 3, 1, 9, 0, 0);
appointment.End = appointment.Start.AddHours(2);

//Save the appointment.
appointment.Save(SendInvitationsMode.SendToNone);

如何使用 API 检查预订状态以及是否由于日期冲突(成功/错误/冲突)而被预订?现在我可以通过 Outlook 进行检查,但我想从 API 中了解这些信息。我查看了 API 文档,但找不到任何东西。

感谢您的帮助/指导。

4

1 回答 1

3

在保存约会之前,您应该首先检查所有与会者的可用性。AvailabilityData将返回您Result(ServiceResult.Success、ServiceResult.Warning 或 ServiceResult.Error),并且您可以进一步检查ErrorMessage属性以找到每个冲突可用性的正确返回消息。如果任何与会者的可用性没有冲突,您可以保存您的约会对象。

AvailabilityOptions availabilityOptions = new AvailabilityOptions();
availabilityOptions.MeetingDuration = 60;
availabilityOptions.MaximumNonWorkHoursSuggestionsPerDay = 4;
availabilityOptions.MinimumSuggestionQuality = SuggestionQuality.Good;
availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy;

List<AttendeeInfo> attendees = new List<AttendeeInfo>();
attendees.Add(
    new AttendeeInfo()
    {
        SmtpAddress = "org@acme.com",
        AttendeeType = MeetingAttendeeType.Organizer
    });

attendees.Add(
    new AttendeeInfo()
    {
        SmtpAddress = "at1@acme.com",
        AttendeeType = MeetingAttendeeType.Required
    });

attendees.Add(
    new AttendeeInfo()
    {
        SmtpAddress = "room1@acme.com",
        AttendeeType = MeetingAttendeeType.Room
    });

GetUserAvailabilityResults availabilityResults =
        service.GetUserAvailability(
            attendees,
            new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)),
            AvailabilityData.FreeBusyAndSuggestions,
            availabilityOptions
        );

// Here check the availability Result and ErrorMessage of each attendees
// availabilityResults.AttendeesAvailability[0].Result
// availabilityResults.AttendeesAvailability[0].ErrorMessage
// ServiceResult.Success
// ServiceResult.Warning
// ServiceResult.Error
于 2013-05-17T20:47:13.157 回答