Appointment.Bind 之后 Appointment.Resources 中没有 EWS 资源

EWS No Resources in Appointment.Resources after Appointment.Bind

我正在使用 EWS Managed API 加载特定房间资源的约会,并通过 WCF 发布它以供平板设备使用。

如果会议预定开始 15 分钟后组织者未执行特定操作,我想取消会议室预订。

因为平板设备只有StoreId 属性来识别事件,我实现了以下代码:

public bool CancelMeeting(string appointmentId, string roomEmail)
    {
        try
        {
            var service = GetExchangeService();
            var ai = new AlternateId[1];
            ai[0] = new AlternateId();
            ai[0].UniqueId = appointmentId;
            ai[0].Format = IdFormat.HexEntryId;
            ai[0].Mailbox = roomEmail;
            ServiceResponseCollection<ConvertIdResponse> cvtresp = service.ConvertIds(ai, IdFormat.EwsId);
            var appointment = Appointment.Bind(service, ((AlternateId)cvtresp[0].ConvertedId).UniqueId);

            if (appointment.Resources.Count != 0)
                appointment.Resources.RemoveAt(0);

            appointment.Location = string.Empty;

            appointment.Save(SendInvitationsMode.SendOnlyToAll);
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }

然而,

if (appointment.Resources.Count != 0)
    appointment.Resources.RemoveAt(0);

在此代码中 appointment.Resources.Count 始终为 0。根据此 post (Can't Retrieve Resources (rooms) from Exchange Web Services),您需要告诉 EWS 明确包含资源。使用Appointment.Bind时如何指定包含资源?

与您链接的 post 大致相同。使用 AppointmentSchema.Resources 属性 创建一个 属性 集并将其传递给 Bind 方法。

PropertySet includeResources = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.Resources);
var appointment = Appointment.Bind(service, ((AlternateId)cvtresp[0].ConvertedId).UniqueId, includeResources);

更新:

您似乎正在访问聊天室的日历,而不是组织者。在房间的日历中,您看不到资源。资源仅在组织者的日历中可见。这是因为它们是作为密件抄送收件人实施的。另请记住,从房间的约会副本中删除某些内容不会将其从其他任何人邮箱中的约会中删除,因此这可能不是最佳方法。相反,您可能想要拒绝会议,这会向组织者发回拒绝通知并将会议从会议室的日历中删除。