Exemple #1
0
        /// <summary>
        /// 委托创建会议
        /// </summary>
        /// <param name="ap">会议属性</param>
        /// <param name="config"></param>
        /// <param name="senderEmailAddress">发送者邮箱地址</param>
        public static bool DelegateAccessCreateMeeting(AppointmentProperty ap, ExchangeAdminConfig config, string senderEmailAddress)
        {
            InitializeEws(config);
            Appointment meeting = new Appointment(Service);


            // Set the properties on the meeting object to create the meeting.
            meeting.Subject  = ap.Subject;
            meeting.Body     = ap.Body;
            meeting.Start    = ap.Start;
            meeting.End      = ap.End;
            meeting.Location = ap.Location;
            //添加与会者
            foreach (string attendee in ap.Attendees)
            {
                meeting.RequiredAttendees.Add(new Attendee(attendee));
            }

            meeting.ReminderMinutesBeforeStart = 60;

            // Save the meeting to the Calendar folder for
            // the mailbox owner and send the meeting request.
            // This method call results in a CreateItem call to EWS.
            meeting.Save(new FolderId(WellKnownFolderName.Calendar, senderEmailAddress), SendInvitationsMode.SendToAllAndSaveCopy);

            // Verify that the meeting was created.
            Item item = Item.Bind(Service, meeting.Id, new PropertySet(ItemSchema.Subject));

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// 获取当前用户指定时间段的会议列表
        /// </summary>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="config"></param>
        /// <returns>会议列表</returns>
        public static List <AppointmentProperty> GetAppointment(DateTime start, DateTime end, ExchangeAdminConfig config)
        {
            InitializeEws(config);
            //要返回的会议列表
            List <AppointmentProperty> appointments = new List <AppointmentProperty>();
            //要获取的时间段
            CalendarView cv = new CalendarView(start, end);
            FindItemsResults <Appointment> aps = Service.FindAppointments(WellKnownFolderName.Calendar, cv);

            foreach (Appointment ap in aps)
            {
                //定义需要的会议属性
                PropertyDefinitionBase[] bas = new PropertyDefinitionBase[]
                {
                    ItemSchema.Id, AppointmentSchema.Start, AppointmentSchema.End, ItemSchema.Subject,
                    ItemSchema.Body, AppointmentSchema.RequiredAttendees, AppointmentSchema.Location
                };

                PropertySet         props       = new PropertySet(bas);
                Appointment         email       = Appointment.Bind(Service, ap.Id, props);
                AppointmentProperty appointment = new AppointmentProperty();
                appointment.Start     = email.Start;
                appointment.End       = email.End;
                appointment.Body      = email.Body;
                appointment.Subject   = email.Subject;
                appointment.Location  = email.Location;
                appointment.Attendees = email.RequiredAttendees.Select(p => p.Address).ToList();
                appointment.ID        = email.Id;

                appointments.Add(appointment);
            }
            return(appointments);
        }
Exemple #3
0
        /// <summary>
        /// 保存会议
        /// </summary>
        /// <param name="ap">会议属性</param>
        /// <param name="config"></param>
        /// <returns>保存结果</returns>
        public static bool CreateAppointment(AppointmentProperty ap, ExchangeAdminConfig config)
        {
            try
            {
                InitializeEws(config);
                //初始化会议对象
                Appointment appointment = new Appointment(Service);
                //会议主题
                appointment.Subject = ap.Subject;
                //会议内容
                appointment.Body = ap.Body;
                //会议开始
                appointment.Start = ap.Start;
                //会议结束
                appointment.End = ap.End;
                //会议的位置
                appointment.Location = ap.Location;
                //添加与会者
                foreach (string attendee in ap.Attendees)
                {
                    appointment.RequiredAttendees.Add(new Attendee(attendee));
                }
                //保存会议
                appointment.Save();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw;
            }
        }