Asp.net/ews会议请求获得与会者

本文关键字:与会者 请求 会议 net ews Asp | 更新日期: 2023-09-27 18:05:58

我正在尝试通过asp.net应用程序发送会议请求,然后检查与会者是否接受。

我使用的第一个方法:"发送会议请求"

    protected void meetingTest_Click(object sender, EventArgs e)
    {
        string[] split = User.Identity.Name.Split('''');
        string userTag = split[1];
        Active_Directory ad = new Active_Directory();
        string creator = ad.convertForUserInfo(userTag, "email");

        ExchangeService service = new ExchangeService();
        service.AutodiscoverUrl(creator);
        Appointment meeting = new Appointment(service);
        meeting.Subject = "test";
        meeting.Body = "test2";
        meeting.Start = DateTime.Now.AddDays(2);
        meeting.End = meeting.Start.AddHours(4);
        meeting.Location = "test3";
        meeting.RequiredAttendees.Add("Attendee´s emailadress");
        meeting.ReminderMinutesBeforeStart = 60;
        meeting.Save(SendInvitationsMode.SendToAllAndSaveCopy);

        checkMeetings();
    }

发送部分工作正常,我在outlook中收到会议请求,我可以在那里看到所需的与会者。

现在这里是我的方法来获得所需的与会者和他们的状态:

    private void checkMeetings()
    {
        string[] split = User.Identity.Name.Split('''');
        string userTag = split[1];
        Active_Directory ad = new Active_Directory();
        string creator = ad.convertForUserInfo(userTag, "email");
        ExchangeService service = new ExchangeService();
        service.AutodiscoverUrl(creator);
        CalendarFolder folder = CalendarFolder.Bind(service, WellKnownFolderName.Calendar);
        CalendarView view = new CalendarView(Convert.ToDateTime("03.08.2015 08:00"),Convert.ToDateTime("08.08.2015 08:00"));
        FindItemsResults<Appointment> results = folder.FindAppointments(view);
        foreach (Appointment appointment in results)
        {
            var attendees = appointment.RequiredAttendees;
            Test1.Text += appointment.RequiredAttendees.Count() + "***";
            foreach (var attend in appointment.RequiredAttendees)
            {
                Test2.Text += attend.Name + " " + attend.ResponseType + "***";
            }
            //Test2.Text += appointment.Subject + "***";
        }
    }

我现在的问题是,"appointment.RequiredAttendees.count()"是0,即使我在发送会议请求时添加了与会者…

有人知道为什么吗?或者有一个更简单的解决方案,我还没有找到?

Asp.net/ews会议请求获得与会者

好的,我找到了一个解决我自己问题的方法,如果有人遇到同样的问题,我要把它贴出来。

    private void checkMeetings()
    {
        string[] split = User.Identity.Name.Split('''');
        string userTag = split[1];
        Active_Directory ad = new Active_Directory();
        string creator = ad.convertForUserInfo(userTag, "email");
        ExchangeService service = new ExchangeService();
        service.AutodiscoverUrl(creator);
        CalendarFolder folder = CalendarFolder.Bind(service, WellKnownFolderName.Calendar);
        CalendarView view = new CalendarView(Convert.ToDateTime("03.08.2015 08:00"),Convert.ToDateTime("08.08.2015 08:00"));
        FindItemsResults<Appointment> results = folder.FindAppointments(view);
        foreach (Appointment appointment in results)
        {
            Appointment appointmentDetailed = Appointment.Bind(service, appointment.Id, new PropertySet(BasePropertySet.FirstClassProperties) { RequestedBodyType = BodyType.Text });
            foreach (Attendee attendee in appointmentDetailed.RequiredAttendees)
            {
                Test2.Text += attendee.Name + " " + attendee.ResponseType + "***";
            }
        }
    }

修复它的部分是:

Appointment Appointment. detail =约会。Bind(服务,约会。Id, new PropertySet(BasePropertySet.FirstClassProperties) {requestdbodytype = BodyType。

文本});

现在我可以得到每个与会者,看看他们是否接受它

加载附加属性的更好的方法是:

private void checkMeetings()
{
    string[] split = User.Identity.Name.Split('''');
    string userTag = split[1];
    Active_Directory ad = new Active_Directory();
    string creator = ad.convertForUserInfo(userTag, "email");
    ExchangeService service = new ExchangeService();
    service.AutodiscoverUrl(creator);
    CalendarFolder folder = CalendarFolder.Bind(service, WellKnownFolderName.Calendar);
    CalendarView view = new CalendarView(Convert.ToDateTime("03.08.2015 08:00"),Convert.ToDateTime("08.08.2015 08:00"));
    FindItemsResults<Appointment> results = folder.FindAppointments(view);
    service.LoadPropertiesForItems(appointments, new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.RequiredAttendees));
    foreach (Appointment appointment in results)
    {
        foreach (Attendee attendee in appointment.RequiredAttendees)
        {
            Test2.Text += attendee.Name + " " + attendee.ResponseType + "***";
        }
    }
}

重要的一行是这一行:

service.LoadPropertiesForItems(appointments, new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.RequiredAttendees));