当前位置: 首页>>代码示例>>C#>>正文


C# ExchangeService.CreateItems方法代码示例

本文整理汇总了C#中ExchangeService.CreateItems方法的典型用法代码示例。如果您正苦于以下问题:C# ExchangeService.CreateItems方法的具体用法?C# ExchangeService.CreateItems怎么用?C# ExchangeService.CreateItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExchangeService的用法示例。


在下文中一共展示了ExchangeService.CreateItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateCalendarEvent

        public  bool CreateCalendarEvent(ExchangeService service,Appointment objAppointment,string[] rqdAttendeelist,string[] optionalAttendeelist)
        {          
            try
            {             

                ItemView itemView = new ItemView(100);
                itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                List<Appointment> ToCreate = new List<Appointment>();
                Appointment appointment = new Appointment(service);
                appointment.Subject = objAppointment.Subject;// "Calendar Request from Console App";
                appointment.Location = objAppointment.Location;// "Office365";
                appointment.Start = TimeZoneInfo.ConvertTimeToUtc(objAppointment.Start, TimeZoneInfo.Local);
                appointment.End = TimeZoneInfo.ConvertTimeToUtc(objAppointment.End, TimeZoneInfo.Local);// objAppointment.End;
                appointment.Body = objAppointment.Body;
                appointment.IsReminderSet = objAppointment.IsReminderSet;           
                appointment.IsResponseRequested = false;
                foreach(string req in rqdAttendeelist)
                {
                    appointment.RequiredAttendees.Add(req);
                }
                foreach (string opt in optionalAttendeelist)
                {
                    appointment.OptionalAttendees.Add(opt);
                }
                ToCreate.Add(appointment);
                ServiceResponseCollection<ServiceResponse> CreateResponse = service.CreateItems(ToCreate, WellKnownFolderName.Calendar, MessageDisposition.SaveOnly, SendInvitationsMode.SendOnlyToAll);
                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                service = null;
            }
        }
开发者ID:prashanthganathe,项目名称:PersonalProjects,代码行数:37,代码来源:EWSClass.cs

示例2: AddHolidays

        /**
         * Function Add the Holidays
         **/
        static void AddHolidays(ExchangeService service, List<string[]> holidays, List<string> mailboxes)
        {
            // Log file
            string datetimeString = DateTime.Now.ToString("MMddyyyy");
            string logfile = "../../logs/" + datetimeString + "_add_holiday_log.txt";

            //Initiate Error List
            List<string> mbs = new List<string>();

            using (System.IO.StreamWriter log = new System.IO.StreamWriter(@logfile, true))
            {

                // Loop through each email address in the passed in mailboxes List
                foreach (string mailbox in mailboxes)
                {

                    // Impersonate that User
                    service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, mailbox);
                    Console.WriteLine("Attempting to Add Holidays to: " + mailbox);

                    List<Appointment> uga_holidays = new List<Appointment>();

                    // Loop through all the holidays
                    foreach (string[] holiday in holidays)
                    {

                        //Create a new appointment
                        Appointment appointment = new Appointment(service);

                        // Set details
                        appointment.Subject = holiday[0];
                        appointment.Start = DateTime.Parse(holiday[1]);
                        appointment.End = appointment.Start.AddDays(1);
                        appointment.IsAllDayEvent = true;
                        StringList categories = new Microsoft.Exchange.WebServices.Data.StringList();
                        categories.Add("Holiday");
                        appointment.Categories = categories;
                        appointment.IsReminderSet = false;

                        uga_holidays.Add(appointment);

                    }

                    // Save and Send
                    try
                    {
                        service.CreateItems(uga_holidays, WellKnownFolderName.Calendar, MessageDisposition.SaveOnly, SendInvitationsMode.SendToNone);
                        Console.WriteLine("Added Holiday Successfully to: " + mailbox);

                        DateTime now = DateTime.Now;
                        log.WriteLine(now + " - Added holidays succesfully to Mailbox: " + mailbox);

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error During Initial Add - Mailbox: " + mailbox + "; Exception thrown: " + ex);
                        log.WriteLine("Error During Initial Add - Mailbox: " + mailbox + "; Exception thrown: " + ex);
                        mbs.Add(mailbox);

                    }

                    // Clear impersonation.
                    service.ImpersonatedUserId = null;

                }

                //Process Rerun List
                if (mbs.Count > 0)
                {
                    Console.WriteLine("Looping through re-run mailboxes.");

                    while (mbs.Count > 0)
                    {
                        // Current mailbox
                        string mb = mbs.ElementAt(0);
                        Console.WriteLine("On Mailbox: " + mb);

                        // Take the mailbox out of the first element slot
                        log.WriteLine("Removing mailbox " + mb + " from beginning of mbs.");
                        mbs.RemoveAt(0);
                        mbs.TrimExcess();

                        try
                        {
                            // Reruns: Removes
                            // Run search
                            // Impersonate that User
                            service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, mb);

                            // Search String
                            String category = "Holiday";
                            // Search Filter
                            SearchFilter.IsEqualTo filter = new SearchFilter.IsEqualTo(AppointmentSchema.Categories, category);

                            // Result Return Size, number of items
                            ItemView holidayView = new ItemView(100);
                            // Limit data to only necesary components
//.........这里部分代码省略.........
开发者ID:rachelmoorehead,项目名称:rockeagle2013,代码行数:101,代码来源:Program.cs


注:本文中的ExchangeService.CreateItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。