/// <summary>
        /// Updates the appointments (GlobalAppointmentID) with new SyncIDs
        /// </summary>
        /// <param name="idMapping">GlobalAppointmentID -> SyncID</param>
        public void UpdateSyncIDs(Dictionary <string, string> idMapping)
        {
            foreach (KeyValuePair <string, string> entry in idMapping)
            {
                Outlook.AppointmentItem foundItem = _customCalendar.Items.Find(String.Format("[GAI] = '{0}'", entry.Key));

                // updating the SyncIDs
                if (foundItem.ItemProperties[ITEM_PROPERTY_SYNC_ID] == null)
                {
                    foundItem.ItemProperties.Add(ITEM_PROPERTY_SYNC_ID, Outlook.OlUserPropertyType.olText);
                    foundItem.Save();
                }

                foundItem.ItemProperties[ITEM_PROPERTY_SYNC_ID].Value = entry.Value;
                foundItem.Save();

                // updating the information, that this item was updated by the sync
                if (foundItem.ItemProperties[ITEM_PROPERTY_SYNC_UPDATE] == null)
                {
                    foundItem.ItemProperties.Add(ITEM_PROPERTY_SYNC_UPDATE, Outlook.OlUserPropertyType.olText);
                    foundItem.Save();
                }

                foundItem.ItemProperties[ITEM_PROPERTY_SYNC_UPDATE].Value = foundItem.LastModificationTime;
                foundItem.Save();

                Marshal.ReleaseComObject(foundItem);
                foundItem = null;
            }
        }
        /// <summary>
        /// Executed when a new item is added to the calendar folder, and is adding additional parameters to it
        /// </summary>
        /// <param name="Item"></param>
        private void Items_ItemAdd(object Item)
        {
            Outlook.AppointmentItem item = Item as Outlook.AppointmentItem;

            //Debug.WriteLine("CalendarHandler: Items_ItemAdd fired for '" + item.Subject + "'");

            // GAI (GlobalAppointmentID) needs to be added as item property, otherwise it cannot be found later
            Outlook.ItemProperty newPropGAI = item.ItemProperties.Add(ITEM_PROPERTY_GLOBAL_A_ID, Outlook.OlUserPropertyType.olText);
            item.Save();
            newPropGAI.Value = item.GlobalAppointmentID;
            item.Save();

            Marshal.ReleaseComObject(item);
            item = null;
        }
Пример #3
0
        public void TestExtendedProps()
        {
            sync.SyncOption = SyncOption.MergeOutlookWins;

            // create new appointment to sync
            Outlook.AppointmentItem outlookAppointment = AppointmentsSynchronizer.CreateOutlookAppointmentItem(AppointmentsSynchronizer.SyncAppointmentsFolder);
            outlookAppointment.Subject     = name;
            outlookAppointment.Start       = DateTime.Now;
            outlookAppointment.Start       = DateTime.Now;
            outlookAppointment.AllDayEvent = true;

            outlookAppointment.Save();

            var googleAppointment = Factory.NewEvent();

            sync.appointmentsSynchronizer.UpdateAppointment(outlookAppointment, ref googleAppointment);

            Assert.AreEqual(name, googleAppointment.Summary);

            // read appointment from google
            googleAppointment = null;
            MatchAppointments(sync);
            AppointmentsMatcher.SyncAppointments(sync.appointmentsSynchronizer);

            AppointmentMatch match = FindMatch(outlookAppointment);

            Assert.IsNotNull(match);
            Assert.IsNotNull(match.GoogleAppointment);

            // get extended prop
            Assert.AreEqual(AppointmentPropertiesUtils.GetOutlookId(outlookAppointment), AppointmentPropertiesUtils.GetGoogleOutlookAppointmentId(sync.SyncProfile, match.GoogleAppointment));

            DeleteTestAppointments(match);
        }
Пример #4
0
        public void CreateItems(Events newItems)
        {
            foreach (Event item in newItems)
            {
                OutlookInterop.AppointmentItem newEvent = mAPI.Items.Add();
                newEvent.StartTimeZone = mAPI.Application.TimeZones[item.StartTimeZone];
                newEvent.StartUTC      = item.StartUTC.Value;
                newEvent.EndTimeZone   = mAPI.Application.TimeZones[item.EndTimeZone];
                newEvent.EndUTC        = item.EndUTC.Value;

                newEvent.Subject     = item.Subject;
                newEvent.Location    = item.Location;
                newEvent.AllDayEvent = item.AllDayEvent;

                newEvent.ReminderMinutesBeforeStart = item.ReminderMinutesBefore;
                newEvent.ReminderSet = item.ReminderOn;

                switch (item.Status)
                {
                case Event.StatusEnum.Free: newEvent.BusyStatus = OutlookInterop.OlBusyStatus.olFree; break;

                case Event.StatusEnum.Tentative: newEvent.BusyStatus = OutlookInterop.OlBusyStatus.olTentative; break;

                case Event.StatusEnum.Busy: newEvent.BusyStatus = OutlookInterop.OlBusyStatus.olBusy; break;

                case Event.StatusEnum.OutOfOffice: newEvent.BusyStatus = OutlookInterop.OlBusyStatus.olOutOfOffice; break;

                case Event.StatusEnum.ElseWhere: newEvent.BusyStatus = OutlookInterop.OlBusyStatus.olWorkingElsewhere; break;

                default: newEvent.BusyStatus = OutlookInterop.OlBusyStatus.olFree; break;
                }

                newEvent.Save();
            }
        }
Пример #5
0
        private void Load_Click(object sender, RoutedEventArgs e)
        {
            if (reaminder_checkBox.IsChecked.Value)
            {
                Outlook.Application outlookApp = new Outlook.Application();

                Outlook.AppointmentItem appt = outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
                appt.Subject     = "Follow up for" + jobTitle.Text + " post " + companyName.Text;
                appt.Location    = "NA";
                appt.Body        = "Follow up with the HR/Website for the Status ";
                appt.Sensitivity = Outlook.OlSensitivity.olPrivate;
                appt.Start       = DateTime.Parse(remainder_date.SelectedDate.ToString());
                appt.End         = DateTime.Parse(remainder_date.SelectedDate.ToString().Replace("00:00", "10:00"));
                appt.ReminderSet = true;
                appt.ReminderMinutesBeforeStart = 0;
                appt.Save();
            }
            if (save_new_data())
            {
                load_table();
            }
            else
            {
                MessageBox.Show("Data Invalid:Please check");
            }
        }
Пример #6
0
        //gavdcodeend 08

        //gavdcodebegin 09
        private void btnCreateAppointment_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.Application myApplication = Globals.ThisAddIn.Application;

            Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)
                                                     myApplication.CreateItem(Outlook.OlItemType.olAppointmentItem);

            newAppointment.Start       = DateTime.Now.AddHours(1);
            newAppointment.End         = DateTime.Now.AddHours(2);
            newAppointment.Location    = "An Empty Room";
            newAppointment.Body        = "This is a test appointment";
            newAppointment.AllDayEvent = false;
            newAppointment.Subject     = "My test";
            newAppointment.Recipients.Add("Somebody, He Is");

            Outlook.Recipients sentAppointmentTo = newAppointment.Recipients;
            Outlook.Recipient  sentInvite        = null;
            sentInvite      = sentAppointmentTo.Add("b, bbb b");
            sentInvite.Type = (int)Outlook.OlMeetingRecipientType.olRequired;
            sentInvite      = sentAppointmentTo.Add("c, ccc c");
            sentInvite.Type = (int)Outlook.OlMeetingRecipientType.olOptional;
            sentAppointmentTo.ResolveAll();
            newAppointment.Save();
            newAppointment.Display(true);
        }
        private void createAppointment(string startTime, string endTime, String subject, String body, int busyStat)
        {
            Outlook._Application    _app = new Outlook.Application();
            Outlook.AppointmentItem ai   = (Outlook.AppointmentItem)_app.CreateItem(Outlook.OlItemType.olAppointmentItem);



            //MessageBox.Show("startTimeString: " + startTime + " endTime: " + endTime, "data", MessageBoxButtons.OK);
            ai.Subject     = subject;
            ai.AllDayEvent = false;
            ai.Start       = DateTime.Parse(startTime);
            ai.End         = DateTime.Parse(endTime);

            switch (busyStat)
            {
            case 0:
                ai.BusyStatus = Outlook.OlBusyStatus.olFree;
                break;

            case 1:
                ai.BusyStatus = Outlook.OlBusyStatus.olTentative;
                break;

            case 2:
                ai.BusyStatus = Outlook.OlBusyStatus.olBusy;
                break;

            case 3:
                ai.BusyStatus = Outlook.OlBusyStatus.olOutOfOffice;
                break;
            }

            ai.Body = body;
            ai.Save();
        }
Пример #8
0
        /// <summary>
        /// 创建约会.
        /// </summary>
        /// <param name="satrtDateTime">开始时间</param>
        /// <param name="endDateTime">结束时间</param>
        /// <param name="reminderMinutesBeforeStart">提前多长时间提醒</param>
        /// <param name="subject">标题</param>
        /// <param name="body">内容</param>
        public void CreateAppointment(
            DateTime satrtDateTime,
            DateTime endDateTime,
            int reminderMinutesBeforeStart,
            string subject,
            string body
            )
        {
            // 创建约会.
            Outlook.AppointmentItem outLookAppointmentItem =
                (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);

            // 开始时间
            outLookAppointmentItem.Start = satrtDateTime;
            // 结束时间
            outLookAppointmentItem.End = endDateTime;

            // 提前多长时间提醒
            outLookAppointmentItem.ReminderMinutesBeforeStart = reminderMinutesBeforeStart;
            // 标题
            outLookAppointmentItem.Subject = subject;
            // 内容
            outLookAppointmentItem.Body = body;

            // 保存.
            outLookAppointmentItem.Save();
        }
Пример #9
0
 //<Snippet1>
 private void AddAppointment()
 {
     try
     {
         Outlook.AppointmentItem newAppointment =
             (Outlook.AppointmentItem)
             this.Application.CreateItem(Outlook.OlItemType.olAppointmentItem);
         newAppointment.Start    = DateTime.Now.AddHours(2);
         newAppointment.End      = DateTime.Now.AddHours(3);
         newAppointment.Location = "ConferenceRoom #2345";
         newAppointment.Body     =
             "We will discuss progress on the group project.";
         newAppointment.AllDayEvent = false;
         newAppointment.Subject     = "Group Project";
         newAppointment.Recipients.Add("Roger Harui");
         Outlook.Recipients sentTo     = newAppointment.Recipients;
         Outlook.Recipient  sentInvite = null;
         sentInvite      = sentTo.Add("Holly Holt");
         sentInvite.Type = (int)Outlook.OlMeetingRecipientType
                           .olRequired;
         sentInvite      = sentTo.Add("David Junca ");
         sentInvite.Type = (int)Outlook.OlMeetingRecipientType
                           .olOptional;
         sentTo.ResolveAll();
         newAppointment.Save();
         newAppointment.Display(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("The following error occurred: " + ex.Message);
     }
 }
Пример #10
0
 private void OutlookApp()
 {
     Outlook.AppointmentItem appItem    = null;
     Outlook.Application     OutlookApp = new Outlook.Application();
     try
     {
         appItem = OutlookApp.Application.CreateItem(
             Outlook.OlItemType.olAppointmentItem)
                   as Outlook.AppointmentItem;
         appItem.Subject     = _subject;
         appItem.AllDayEvent = true;
         appItem.Start       = DateTime.Parse(_startDate + " 09:00 AM");
         appItem.End         = DateTime.Parse(_endDate + "05:00 PM");
         appItem.Save();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         if (appItem != null)
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(appItem);
         }
         if (OutlookApp != null)
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(OutlookApp);
         }
     }
 }
Пример #11
0
        public void MyAfterItemAdded(object obj)
        {
            Outlook.AppointmentItem aitem = obj as Outlook.AppointmentItem;
            if (aitem == null || aitem.IsRecurring ||
                aitem.MeetingStatus != Outlook.OlMeetingStatus.olNonMeeting)
            {
                return;
            }

            Helpers.DebugInfo("ItemAdded callback is fired with appointment: Id: " + aitem.GlobalAppointmentID +
                              " Subject: " + aitem.Subject + " Duration: " + aitem.Duration);

            if (aitem.UserProperties.Find(_RestoredFromDeletedProperty) != null)
            {
                aitem.UserProperties.Find(_RestoredFromDeletedProperty).Delete();
            }
            else
            {
                if (aitem.UserProperties.Find(_TaskIdProperty) != null ||
                    aitem.UserProperties.Find(_TimeReportedProperty) != null ||
                    aitem.UserProperties.Find(_PreviousAssignedSubjectProperty) != null)
                {
                    aitem.Categories = "";
                }
                DeleteProperty(aitem, _TaskIdProperty);
                DeleteProperty(aitem, _TimeReportedProperty);
                DeleteProperty(aitem, _PreviousAssignedSubjectProperty);
            }
            aitem.Save();

            // outlook sends events in really random order => trying to speed-up it
            MyAfterItemChanged(obj);
        }
        public void                 CalendarItemUpdate(Appointment appointment, WorkflowState workflowState, bool resetBody)
        {
            Outlook.AppointmentItem item = AppointmentItemFind(appointment.GlobalId, appointment.Start);

            item.Body     = appointment.Body;
            item.Location = workflowState.ToString();
            #region item.Categories = 'workflowState'...
            switch (workflowState)
            {
            case WorkflowState.Planned:
                item.Categories = null;
                break;

            case WorkflowState.Processed:
                item.Categories = "Processing";
                break;

            case WorkflowState.Created:
                item.Categories = "Processing";
                break;

            case WorkflowState.Sent:
                item.Categories = "Sent";
                break;

            case WorkflowState.Retrived:
                item.Categories = "Retrived";
                break;

            case WorkflowState.Completed:
                item.Categories = "Completed";
                break;

            case WorkflowState.Canceled:
                item.Categories = "Canceled";
                break;

            case WorkflowState.Revoked:
                item.Categories = "Revoked";
                break;

            case WorkflowState.Failed_to_expection:
                item.Categories = "Error";
                break;

            case WorkflowState.Failed_to_intrepid:
                item.Categories = "Error";
                break;
            }
            #endregion

            if (resetBody)
            {
                item.Body = UnitTest_CalendarBody();
            }

            item.Save();

            log.LogStandard("Not Specified", PrintAppointment(item) + " updated to " + workflowState.ToString());
        }
        private Appointment         CreateAppointment(Appointment appointment)
        {
            try
            {
                Outlook.Application     outlookApp = new Outlook.Application();                                                            // creates new outlook app
                Outlook.AppointmentItem newAppo    = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem); // creates a new appointment

                newAppo.AllDayEvent = false;
                newAppo.ReminderSet = false;

                newAppo.Location = appointment.Location;
                newAppo.Start    = appointment.Start;
                newAppo.Duration = appointment.Duration;
                newAppo.Subject  = appointment.Subject;
                newAppo.Body     = appointment.Body;

                newAppo.Save();
                Appointment returnAppo = new Appointment(newAppo.GlobalAppointmentID, newAppo.Start, newAppo.Duration, newAppo.Subject, newAppo.Location, newAppo.Body, t.Bool(sqlController.SettingRead(Settings.colorsRule)), true, sqlController.Lookup);

                Outlook.MAPIFolder calendarFolderDestination = GetCalendarFolder();
                Outlook.NameSpace  mapiNamespace             = outlookApp.GetNamespace("MAPI");
                Outlook.MAPIFolder oDefault = mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

                if (calendarFolderDestination.Name != oDefault.Name)
                {
                    newAppo.Move(calendarFolderDestination);
                }

                return(returnAppo);
            }
            catch (Exception ex)
            {
                throw new Exception("The following error occurred: " + ex.Message);
            }
        }
Пример #14
0
 private void AddAppointment(string subject, string body, DateTime startTime, DateTime endTime)
 {
     // Source: https://docs.microsoft.com/en-us/visualstudio/vsto/how-to-programmatically-create-appointments
     try
     {
         Outlook.AppointmentItem newAppointment =
             (Outlook.AppointmentItem)
             Application.CreateItem(Outlook.OlItemType.olAppointmentItem);
         newAppointment.Start       = startTime;
         newAppointment.End         = endTime;
         newAppointment.Subject     = subject;
         newAppointment.Body        = body;
         newAppointment.AllDayEvent = true;
         //newAppointment.Recipients.Add("Roger Harui");
         //Outlook.Recipients sentTo = newAppointment.Recipients;
         //Outlook.Recipient sentInvite = null;
         //sentInvite = sentTo.Add("Holly Holt");
         //sentInvite.Type = (int)Outlook.OlMeetingRecipientType
         //    .olRequired;
         //sentInvite = sentTo.Add("David Junca ");
         //sentInvite.Type = (int)Outlook.OlMeetingRecipientType
         //    .olOptional;
         //sentTo.ResolveAll();
         newAppointment.Save();
         //newAppointment.Display(false);
         LogInfo($"Check calendar for \"{subject}\"");
     }
     catch (Exception ex)
     {
         LogInfo("The following error occurred: " + ex.Message);
     }
 }
Пример #15
0
 //create an event/appointment
 private void createAppointment()
 {
     outlook.Application     app        = new outlook.Application();
     outlook.AppointmentItem appoinment = (outlook.AppointmentItem)app.CreateItem(outlook.OlItemType.olAppointmentItem);
     appoinment.Body       = "Somethingg";
     appoinment.Importance = outlook.OlImportance.olImportanceNormal;
     appoinment.Save();   //  =  ((outlook._AppointmentItem)appoinment).Save();
 }
Пример #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // Create the Outlook Application
                Outlook.Application oApp = new Outlook.Application();
                // Create NameSpace
                Outlook.NameSpace oNS = (Outlook.NameSpace)oApp.GetNamespace("MAPI");
                oNS.Logon(null, null, false, false);
                // Get DDS Service Desk Calendar
                Outlook.MAPIFolder oFolder;
                Outlook.Recipient  oRecipient;
                string             calendarName = "*****@*****.**";


                // Create a new appointment item
                Outlook.AppointmentItem oMsg = (Outlook.AppointmentItem)oApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
                // Set Recipients
                oRecipient = oNS.CreateRecipient(calendarName);
                oRecipient.Resolve();
                oFolder = oNS.GetSharedDefaultFolder(oRecipient, Outlook.OlDefaultFolders.olFolderCalendar);
                // Set Appointment Start Time and End Time
                oMsg       = oFolder.Items.Add("IPM.Appointment") as Outlook.AppointmentItem;
                oMsg.Start = DateTime.Parse(dateTimePicker1.Text + " " + comboBox1.Text);
                oMsg.End   = DateTime.Parse(dateTimePicker2.Text + " " + comboBox2.Text);
                //Set the Body
                string message = "The Below Is Information Regarding The IT Equipment Reservation" + Environment.NewLine;
                oMsg.Body = "The Below Is Information Regarding The IT Equipment Reservation" + Environment.NewLine + Environment.NewLine +
                            "Requester Information:" + Environment.NewLine +
                            "Email:" + " " + textBox1.Text + Environment.NewLine +
                            "First Name:" + " " + textBox2.Text + Environment.NewLine +
                            "Last Name:" + " " + textBox3.Text + Environment.NewLine + Environment.NewLine +
                            "Reservation Information:" + Environment.NewLine +
                            "Pick-Up Time:" + " " + comboBox1.Text + " " + "to" + " " + comboBox2.Text + Environment.NewLine +
                            "Pick-Up Date:" + " " + dateTimePicker1.Text + " " + "to" + " " + dateTimePicker2.Text + Environment.NewLine +
                            "Service Request Number:" + " " + textBox8.Text + Environment.NewLine + Environment.NewLine +
                            "Service Request Link:" + " " + "http://oasis.dds.ca.gov/applications/ISDRequests_Staff/index.cfm?pageAction=ShowDetail&RequestNum=" + textBox8.Text + Environment.NewLine +
                            "Reserved By Technician:" + Environment.NewLine +
                            "Email:" + " " + textBox4.Text + Environment.NewLine +
                            "First Name:" + " " + textBox5.Text + Environment.NewLine +
                            "Last Name:" + " " + textBox6.Text + Environment.NewLine +
                            "Telephone Number:" + " " + textBox7.Text + Environment.NewLine + Environment.NewLine +
                            "Comments" + Environment.NewLine +
                            richTextBox1.Text;
                //Set the Subject
                oMsg.Subject = "SR #" + " " + textBox8.Text + " " + textBox2.Text + " " + textBox3.Text + "-" + " Pick Up" + " " + textBox9.Text;
                //Set the location
                oMsg.Location = "DDS Service Desk -- HQ";
                //save the appointment
                oMsg.Save();
                //Show Confirmation Message
                MessageBox.Show("Successful");
            }
            catch (System.Exception ex)
            {
            }
        }
Пример #17
0
 static void Main(string[] args)
 {
     Outlook.Application     ol  = new Outlook.Application();
     Outlook.AppointmentItem cal = ol.CreateItem(Outlook.OlItemType.olAppointmentItem);
     cal.Start   = DateTime.Now;
     cal.End     = DateTime.Now.AddMinutes(30);
     cal.Subject = "Test";
     cal.Save();
 }
Пример #18
0
        private void UpdateSelectedAppointmentsOrCreateNew(string tag)
        {
            Outlook.View view = Globals.ThisAddIn._Explorer.CurrentView as Outlook.View;
            if (view.ViewType != Outlook.OlViewType.olCalendarView)
            {
                return;
            }
            Outlook.Folder       folder  = Globals.ThisAddIn._Explorer.CurrentFolder as Outlook.Folder;
            Outlook.CalendarView calView = view as Outlook.CalendarView;

            if (Globals.ThisAddIn._Explorer.Selection.Count != 0)
            {
                foreach (object obj in Globals.ThisAddIn._Explorer.Selection)
                {
                    Outlook.AppointmentItem aitem = obj as Outlook.AppointmentItem;
                    if (aitem == null)
                    {
                        continue;
                    }

                    if (aitem.IsRecurring ||
                        aitem.MeetingStatus != Outlook.OlMeetingStatus.olNonMeeting)
                    {
                        // clone this appointment
                        DateTime dateStart = aitem.Start;
                        DateTime dateEnd   = aitem.End;
                        aitem             = folder.Items.Add("IPM.Appointment") as Outlook.AppointmentItem;
                        aitem.ReminderSet = false;
                        aitem.Start       = dateStart;
                        aitem.End         = dateEnd;
                    }

                    if (aitem.Subject == null)
                    {
                        aitem.Subject = tag;
                    }
                    else
                    {
                        aitem.Subject = tag + " " + aitem.Subject.Trim();
                    }
                    aitem.Save();
                }
            }
            else
            {
                DateTime dateStart            = calView.SelectedStartTime;
                DateTime dateEnd              = calView.SelectedEndTime;
                Outlook.AppointmentItem aitem = folder.Items.Add("IPM.Appointment") as Outlook.AppointmentItem;
                aitem.ReminderSet = false;
                aitem.Start       = dateStart;
                aitem.End         = dateEnd;
                aitem.Subject     = tag;
                aitem.Save();
            }
        }
        /// <summary>
        /// Creates a new appointment in the custom calendar
        /// </summary>
        /// <param name="appointment">new appointment</param>
        /// <returns>GlobalAppointmentID of the new appointment in Outlook</returns>
        private String CreateAppointment(OutlookAppointment appointment)
        {
            if (_customCalendar == null || appointment == null)
            {
                return(null);
            }

            Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)_customCalendar.Items.Add(Outlook.OlItemType.olAppointmentItem);

            newAppointment.Subject     = appointment.Subject;
            newAppointment.Body        = appointment.Body;
            newAppointment.Start       = appointment.Start;
            newAppointment.End         = appointment.End;
            newAppointment.ReminderSet = false;
            //newAppointment.ReminderMinutesBeforeStart = appointment.ReminderMinutesBeforeStart;
            newAppointment.Location    = appointment.Location;
            newAppointment.AllDayEvent = appointment.AllDayEvent;

            //if (appointment.Attachments != null)
            //newAppointment.Attachments.Add(appointment.Attachments);

            newAppointment.Duration   = appointment.Duration;
            newAppointment.Importance = Outlook.OlImportance.olImportanceNormal;

            // GlobalAppointmentID must be stored as custom item property as well, because GlobalAppointmentID property cannot be searched for
            newAppointment.ItemProperties.Add(ITEM_PROPERTY_GLOBAL_A_ID, Outlook.OlUserPropertyType.olText);
            newAppointment.ItemProperties.Add(ITEM_PROPERTY_SYNC_ID, Outlook.OlUserPropertyType.olText);
            newAppointment.ItemProperties.Add(ITEM_PROPERTY_SYNC_UPDATE, Outlook.OlUserPropertyType.olText);

            newAppointment.Save();

            newAppointment.ItemProperties[ITEM_PROPERTY_GLOBAL_A_ID].Value = newAppointment.GlobalAppointmentID;
            newAppointment.ItemProperties[ITEM_PROPERTY_SYNC_ID].Value     = appointment.SyncID;
            newAppointment.ItemProperties[ITEM_PROPERTY_SYNC_UPDATE].Value = newAppointment.LastModificationTime;

            newAppointment.Save();

            return(newAppointment.GlobalAppointmentID);
        }
Пример #20
0
        public SynchronEvent ConvertOutlookToMyEvent(Microsoft.Office.Interop.Outlook.AppointmentItem outlookItem)
        {
            var result = new SynchronEvent()
                         .SetStart(outlookItem.Start)
                         .SetDuration(outlookItem.Duration)
                         .SetLocation(outlookItem.Location)
                         .SetSubject(outlookItem.Subject)
                         .SetCompanions(outlookItem.RequiredAttendees)
                         .SetId(outlookItem.GlobalAppointmentID)
                         .SetFinish(outlookItem.End)
                         .SetSource(_outlook)
                         .SetDescription(outlookItem.Body)
                         .SetPlacement(_outlook)
                         .SetAllDay(outlookItem.AllDayEvent);

            if (!string.IsNullOrEmpty(outlookItem.Mileage))
            {
                result.SetId(outlookItem.Mileage);
                if (outlookItem.Mileage.IndexOf(_outlook) > -1)
                {
                    result.SetSource(_outlook);
                }
                else
                {
                    result.SetSource(_google);
                    outlookItem.Categories = "Orange Category";
                    outlookItem.Save();
                }
            }
            else
            {
                Guid id = Guid.NewGuid();
                outlookItem.Mileage = _outlook + id.ToString();
                outlookItem.Save();
                result.SetSource(_outlook);
                result.SetId(outlookItem.Mileage);
            }
            return(result);
        }
Пример #21
0
        override public string AddAppointment(SubCalendarEvent ActiveSection, string NameOfParentCalendarEvent = "")
        {
            if (!ActiveSection.isEnabled)
            {
                return("");
            }
#if EnableOutlook
            try
            {
                Outlook.Application     app            = new Microsoft.Office.Interop.Outlook.Application();
                Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)app.CreateItem(Outlook.OlItemType.olAppointmentItem);

                /*(Outlook.AppointmentItem)
                 * this.Application.CreateItem(Outlook.OlItemType.olAppointmentItem);*/
                newAppointment.Start       = ActiveSection.Start.toTimeZoneTime().DateTime; // DateTimeOffset.Now.AddHours(2);
                newAppointment.End         = ActiveSection.End.toTimeZoneTime().DateTime;   // DateTimeOffset.Now.AddHours(3);
                newAppointment.Location    = "TBD";
                newAppointment.Body        = "JustTesting";
                newAppointment.AllDayEvent = false;
                string SubJectString = ActiveSection.getId + "**" + NameOfParentCalendarEvent;
                if (ActiveSection.getIsComplete)
                {
                    //SubJectString = ActiveSection.ID + "*\u221A*" + NameOfParentCalendarEvent;
                }
                newAppointment.Subject = SubJectString;// ActiveSection.ID + "**" + NameOfParentCalendarEvent;

                /*newAppointment.Recipients.Add("Roger Harui");
                 * Outlook.Recipients sentTo = newAppointment.Recipients;
                 * Outlook.Recipient sentInvite = null;
                 * sentInvite = sentTo.Add("Holly Holt");
                 * sentInvite.Type = (int)Outlook.OlMeetingRecipientType
                 *  .olRequired;
                 * sentInvite = sentTo.Add("David Junca ");
                 * sentInvite.Type = (int)Outlook.OlMeetingRecipientType
                 *  .olOptional;
                 * sentTo.ResolveAll();*/
                newAppointment.Save();
                //newAppointment.EntryID;

                //newAppointment.Display(true);
                return(newAppointment.EntryID);
            }
            catch (Exception ex)
            {
                //MessageBox.Show("The following error occurred: " + ex.Message);
                return("");
            }
#endif
            return("");
        }
Пример #22
0
 private void ReminderExample()
 {
     Outlook.AppointmentItem appt = Application.CreateItem(
         Outlook.OlItemType.olAppointmentItem)
                                    as Outlook.AppointmentItem;
     appt.Subject     = "Wine Tasting";
     appt.Location    = "Napa CA";
     appt.Sensitivity = Outlook.OlSensitivity.olPrivate;
     appt.Start       = DateTime.Parse("10/21/2006 10:00 AM");
     appt.End         = DateTime.Parse("10/21/2006 3:00 PM");
     appt.ReminderSet = true;
     appt.ReminderMinutesBeforeStart = 120;
     appt.Save();
 }
Пример #23
0
        public void MyAfterItemChanged(object obj)
        {
            Outlook.AppointmentItem aitem = obj as Outlook.AppointmentItem;
            if (aitem == null || aitem.IsRecurring ||
                aitem.MeetingStatus != Outlook.OlMeetingStatus.olNonMeeting)
            {
                return;
            }

            Helpers.DebugInfo("ItemChanged callback is fired with appointment: Id: " + aitem.GlobalAppointmentID +
                              " Subject: " + aitem.Subject + " Duration: " + aitem.Duration);

            if (aitem.UserProperties.Find(_TimeReportedProperty) == null ||
                aitem.UserProperties.Find(_TaskIdProperty) == null)
            {
                _DelayedReportingQueue.Add(new DelayedReporting(aitem, DelayedReporting.Mode.New));
                _ReportingQueueTimer.Start();
                return;
            }
            if (aitem.Categories != _CategoryName)
            {
                Helpers.DebugInfo("Reverted category");
                aitem.Categories = _CategoryName;
                aitem.Save();
            }
            if (aitem.Subject != aitem.UserProperties.Find(_PreviousAssignedSubjectProperty).Value)
            {
                Helpers.DebugInfo("Reverted subject: old: " + aitem.Subject + " new: " + aitem.UserProperties.Find(_PreviousAssignedSubjectProperty).Value);
                aitem.Subject = aitem.UserProperties.Find(_PreviousAssignedSubjectProperty).Value;
                aitem.Save();
            }
            if (aitem.Duration != aitem.UserProperties.Find(_TimeReportedProperty).Value)
            {
                _DelayedReportingQueue.Add(new DelayedReporting(aitem, DelayedReporting.Mode.Edit));
                _ReportingQueueTimer.Start();
            }
        }
Пример #24
0
        private void ReminderExample()
        {
            Outlook.Application outlookApp = new Outlook.Application();

            Outlook.AppointmentItem appt = outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem)
                                           as Outlook.AppointmentItem;
            appt.Subject     = "Wine Tasting";
            appt.Location    = "Napa CA";
            appt.Sensitivity = Outlook.OlSensitivity.olPrivate;
            appt.Start       = new DateTime(2013, 01, 24, 20, 55, 00); //DateTime.Parse("10/21/2006 10:00 AM");
            appt.End         = new DateTime(2013, 01, 24, 22, 55, 00); //DateTime.Parse("10/21/2006 3:00 PM");
            appt.ReminderSet = true;
            appt.ReminderMinutesBeforeStart = 8;
            appt.Save();
        }
Пример #25
0
        private void UpdateAppointment(Outlook.AppointmentItem aitem, int id,
                                       string user_title, string work_item_title, int duration)
        {
            string subject_with_time = Helpers.GenerateSubject(id, user_title, true);

            aitem.Categories  = _CategoryName;
            aitem.Subject     = subject_with_time;
            aitem.Duration    = duration;
            aitem.ReminderSet = false;
            aitem.UserProperties.Add(_TimeReportedProperty, Outlook.OlUserPropertyType.olInteger).Value         = duration;
            aitem.UserProperties.Add(_TaskIdProperty, Outlook.OlUserPropertyType.olInteger).Value               = id;
            aitem.UserProperties.Add(_PreviousAssignedSubjectProperty, Outlook.OlUserPropertyType.olText).Value = subject_with_time;
            aitem.Save();
            AddNewRecentWorkItems(Helpers.GenerateSubject(id, work_item_title));
        }
Пример #26
0
        private void button1_Click(object sender, EventArgs e)
        {
            Outlook.Application olApp  = new Outlook.Application();
            Outlook.NameSpace   mapiNS = olApp.GetNamespace("MAPI");

            string profile = "";

            mapiNS.Logon(profile, null, null, null);

            Outlook.AppointmentItem apt = olApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
            apt.Start   = DateTime.Now.AddHours(-3);
            apt.End     = apt.Start.AddHours(1);
            apt.Subject = "Please synch in advance.";
            apt.Save();
            apt.Send();
        }
        public void TestSync_Time()
        {
            sync.SyncOption = SyncOption.MergeOutlookWins;

            // create new appointment to sync
            Outlook.AppointmentItem outlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder);
            outlookAppointment.Subject     = name;
            outlookAppointment.Start       = DateTime.Now;
            outlookAppointment.End         = DateTime.Now.AddHours(1);
            outlookAppointment.AllDayEvent = false;

            outlookAppointment.Save();


            sync.SyncOption = SyncOption.OutlookToGoogleOnly;

            var googleAppointment = Factory.NewEvent();

            sync.UpdateAppointment(outlookAppointment, ref googleAppointment);

            googleAppointment = null;

            sync.SyncOption = SyncOption.GoogleToOutlookOnly;
            //load the same appointment from google.
            MatchAppointments(sync);
            AppointmentMatch match = FindMatch(outlookAppointment);

            Assert.IsNotNull(match);
            Assert.IsNotNull(match.GoogleAppointment);
            Assert.IsNotNull(match.OutlookAppointment);

            Outlook.AppointmentItem recreatedOutlookAppointment = Synchronizer.CreateOutlookAppointmentItem(Synchronizer.SyncAppointmentsFolder);
            sync.UpdateAppointment(ref match.GoogleAppointment, recreatedOutlookAppointment, match.GoogleAppointmentExceptions);
            Assert.IsNotNull(outlookAppointment);
            Assert.IsNotNull(recreatedOutlookAppointment);
            // match recreatedOutlookAppointment with outlookAppointment

            Assert.AreEqual(outlookAppointment.Subject, recreatedOutlookAppointment.Subject);

            Assert.AreEqual(outlookAppointment.Start, recreatedOutlookAppointment.Start);
            Assert.AreEqual(outlookAppointment.End, recreatedOutlookAppointment.End);
            Assert.AreEqual(outlookAppointment.AllDayEvent, recreatedOutlookAppointment.AllDayEvent);
            //ToDo: Check other properties

            DeleteTestAppointments(match);
            recreatedOutlookAppointment.Delete();
        }
Пример #28
0
        private void AddAppointment(string subject, string body, DateTime startdatum, DateTime sluttatum)
        {
            try
            {
                Microsoft.Office.Interop.Outlook.AppointmentItem newAppointment =
                    (Microsoft.Office.Interop.Outlook.AppointmentItem)
                    _application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
                newAppointment.Start       = startdatum;
                newAppointment.End         = sluttatum;
                newAppointment.AllDayEvent = false;
                newAppointment.BusyStatus  = Microsoft.Office.Interop.Outlook.OlBusyStatus.olTentative;
                newAppointment.Location    = "Platsangivelse...";

                // Bifoga ett dokument om så önskas
                OpenFileDialog attachment = new OpenFileDialog();
                attachment.Title = appointheader.Text;
                attachment.ShowDialog();
                if (attachment.FileName.Length > 0)
                {
                    newAppointment.Attachments.Add(attachment.FileName,
                                                   Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue,
                                                   1,
                                                   attachment.FileName);
                }

                Microsoft.Office.Interop.Outlook.Recipients sentTo     = newAppointment.Recipients;
                Microsoft.Office.Interop.Outlook.Recipient  sentInvite = null;
                sentInvite      = sentTo.Add("Holly Holt");
                sentInvite.Type = (int)Microsoft.Office.Interop.Outlook.OlMeetingRecipientType
                                  .olRequired;
                sentInvite      = sentTo.Add("David Junca ");
                sentInvite.Type = (int)Microsoft.Office.Interop.Outlook.OlMeetingRecipientType
                                  .olOptional;
                sentTo.ResolveAll();

                newAppointment.Subject = subject;
                newAppointment.Body    = body;
                newAppointment.Save();
                // newAppointment.Display(true);
                newAppointment.Close(OlInspectorClose.olSave); // Detta gör att man inte behöver stänga dialogen manuellt
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("The following error occurred: " + ex.Message);
            }
        }
Пример #29
0
        private void UpdateAppointmentItem(Outlook.AppointmentItem appoItem, CalendarItem calendarItem)
        {
            if (EqualsAppointmentPropertyString(appoItem.Subject, calendarItem.Name) == false)
            {
                appoItem.Subject = calendarItem.Name;
            }
            if (appoItem.AllDayEvent != calendarItem.AllDayEvent)
            {
                appoItem.AllDayEvent = calendarItem.AllDayEvent;
            }
            if (appoItem.Start != calendarItem.Start)
            {
                appoItem.Start = calendarItem.Start;
            }
            if (appoItem.End != calendarItem.End)
            {
                appoItem.End = calendarItem.End;
            }
            if (EqualsAppointmentPropertyString(appoItem.Location, calendarItem.Location) == false)
            {
                appoItem.Location = calendarItem.Location;
            }
            if (EqualsAppointmentPropertyString(appoItem.Body, calendarItem.Body) == false)
            {
                appoItem.Body = calendarItem.Body;
            }
            var userProp = appoItem.UserProperties[USER_PROPERTY_NAME_GO_CALENDAR_SYNC];

            if (userProp != null)
            {
                var guidStr = calendarItem.SyngronizeGuid.ToString();
                if (userProp.Value != guidStr)
                {
                    userProp.Value = guidStr;
                }
            }
            else
            {
                var p = appoItem.UserProperties.Add(USER_PROPERTY_NAME_GO_CALENDAR_SYNC, Outlook.OlUserPropertyType.olText);
                p.Value = calendarItem.SyngronizeGuid.ToString();
            }
            appoItem.Save();

            var resultCalendarItem = CreateCalendarItem(appoItem);
        }
Пример #30
0
        static void VagtplanOutlook(string pSlutDT)
        {
            DateTime    SlutDT      = DateTime.Parse(pSlutDT);
            clsTemplate objTemplate = new clsTemplate();

            Outlook.Application oApp = new Outlook.Application();
            Outlook.NameSpace   oNS  = oApp.GetNamespace("mapi");
            oNS.Logon(Missing.Value, Missing.Value, true, true);
            Outlook.MAPIFolder oCalendar = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
            Outlook.Items      oItems    = oCalendar.Items;
            string             dayfilter = "[Start] >= '" + DateTime.Today.Date.ToString("g") + "' AND [End] < '" + SlutDT.Date.ToString("g") + "'";
            string             subjectfilter;

            if (oApp.Session.DefaultStore.IsInstantSearchEnabled)
            {
                subjectfilter = "@SQL=\"urn:schemas:httpmail:subject\" ci_startswith '" + objTemplate.Tekst + "'";
            }
            else
            {
                subjectfilter = "@SQL=\"urn:schemas:httpmail:subject\" like '%" + objTemplate.Tekst + "%'";
            }

            Outlook.Items oDagItems = oItems.Restrict(dayfilter).Restrict(subjectfilter);
            for (int i = oDagItems.Count; i > 0; i--)
            {
                oDagItems[i].Delete();
            }

            for (DateTime dt = DateTime.Today; dt.Date <= SlutDT.Date; dt = dt.AddDays(1).Date)
            {
                recTemplate rec = objTemplate.getDag(dt);

                if (!rec.Fri)
                {
                    Outlook.AppointmentItem oAppt = (Outlook.AppointmentItem)oItems.Add(Outlook.OlItemType.olAppointmentItem);
                    oAppt.Subject     = objTemplate.Tekst; // set the subject
                    oAppt.Start       = dt.Date.Add((TimeSpan)rec.Start);
                    oAppt.End         = dt.Date.Add((TimeSpan)rec.S**t);
                    oAppt.ReminderSet = false;                                   // Set the reminder
                    oAppt.Importance  = Outlook.OlImportance.olImportanceNormal; // appointment importance
                    oAppt.BusyStatus  = Outlook.OlBusyStatus.olBusy;
                    oAppt.Save();
                }
            }
        }