【问题标题】:asp.net/ews meeting request get attendeesasp.net/ews 会议请求获取与会者
【发布时间】:2019-08-02 16:53:57
【问题描述】:

我正在尝试通过 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,即使我在发送会议请求时添加了一个与会者...

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

【问题讨论】:

  • sry,我忘了说我是那种东西的新手(asp.net),“会话”是什么意思?
  • 会话将数据保存在您的 ASP 中,以防止在页面回发时丢失数据
  • 在您的会议中试试这个先生Test_Click 在按钮上添加此代码Session["Appointment"] = meeting; 并在您的检查会议方法调用中为您的会话设置一个值,如meeting = (Appointment)Session["Appointment"]; 但我在 ASP.net 中也是新的我希望你能明白......
  • 我尝试了另一种解决方案,它成功了,将其发布在这里!不过谢谢你的回答

标签: c# asp.net exchangewebservices


【解决方案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 + "***";
            }

        }
    }

修复它的部分是:

约会约会Detailed = Appointment.Bind(服务,约会.Id,新PropertySet(BasePropertySet.FirstClassProperties){RequestedBodyType = BodyType.Text});

现在我可以找到每个参加者,看看他们是否接受

【讨论】:

    【解决方案2】:

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

    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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多