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

时间:2015-08-03 08:44:23

标签: c# asp.net exchangewebservices

我正在尝试通过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();
    }

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

现在,我的方法是获取所需的与会者及其状态:

    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,即使我在发送会议请求时添加了与会者...

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

2 个答案:

答案 0 :(得分:1)

好的,我找到了解决自己问题的方法,如果有人遇到同样的问题,我会发布。

    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.Bind(service,appointment.Id,new PropertySet(BasePropertySet.FirstClassProperties){RequestedBodyType = BodyType.Text});

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

答案 1 :(得分:1)

加载其他属性的更好方法是这样的:

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 + "***";
        }

    }
}