public void UpdateAppointment(CalendarItem ev)
        {
            try
            {
                var oldId = ev.CalendarItemIdentifier;
                Log.Write($"Updating recurring Outlook appointment, {ev.Subject}");

                if (!string.IsNullOrEmpty(ev.CalendarItemIdentifier.OutlookEntryId))
                {
                    if (CurrentApplication.Session.GetItemFromID(ev.CalendarItemIdentifier.OutlookEntryId, m_folder.Store.StoreID) is
                        AppointmentItem item)
                    {
                        if (item.RecurrenceState == OlRecurrenceState.olApptMaster)
                        {
                            AppointmentItem temp = ev.GetOutlookAppointment(
                                CurrentApplication.CreateItem(OlItemType.olAppointmentItem));
                            var newMaster = temp.Move(m_folder);

                            item.Delete();
                            newMaster.Save();

                            ev.CalendarItemIdentifier = new Identifier(oldId.GoogleId, oldId.GoogleICalUId, newMaster.EntryID, newMaster.GlobalAppointmentID, EventHasher.GetHash(ev));

                            Marshal.ReleaseComObject(temp);
                            Marshal.ReleaseComObject(newMaster);
                        }
                        else if (item.RecurrenceState == OlRecurrenceState.olApptNotRecurring)
                        {
                            ev.GetOutlookAppointment(item);
                            item.Save();

                            ev.CalendarItemIdentifier = new Identifier(oldId.GoogleId, oldId.GoogleICalUId, item.EntryID, item.GlobalAppointmentID, EventHasher.GetHash(ev));
                        }

                        Marshal.ReleaseComObject(item);
                    }
                }

                ev.Action &= ~CalendarItemAction.GeneratedId;
                ev.Action &= ~CalendarItemAction.OutlookUpdate;

                Log.Write($"Finished updating Outlook appointment, {ev.Subject}");

                Archiver.Instance.UpdateIdentifier(oldId, ev.CalendarItemIdentifier);
            } catch (Exception ex)
            {
                Log.Write(ex, ev);
            }
        }
        public void AddAppointment(CalendarItem item)
        {
            try
            {
                // Create the new appointmentItem and move it into the correct folder. (Ensure to grab the new event after it is moved since "move"
                // will create a copy of the item in the new folder and if you just save it, Outlook will create two copies of the appointment.)
                var tempEvent = item.GetOutlookAppointment((AppointmentItem)CurrentApplication.CreateItem(OlItemType.olAppointmentItem));
                var newEvent  = tempEvent.Move(m_folder);
                newEvent.Save();

                // Update the old Identifier
                var oldId = item.CalendarItemIdentifier;
                // TODO: regenerate hash
                item.CalendarItemIdentifier = new Identifier(oldId.GoogleId, oldId.GoogleICalUId, newEvent.EntryID, newEvent.GlobalAppointmentID, EventHasher.GetHash(item));
                Archiver.Instance.UpdateIdentifier(oldId, item.CalendarItemIdentifier);

                Log.Write($"Added {item} to Outlooks Calendar {m_folder.Name}");

                Marshal.ReleaseComObject(newEvent);
                Marshal.ReleaseComObject(tempEvent);
            } catch (Exception ex)
            {
                Log.Write(ex, item);
                MessageBox.Show("Outlook Sync: The following error occurred: " + ex.Message);
            }
        }