コード例 #1
0
        private void AppointmentItemAction(AppointmentItem appointmentMail)
        {
            appointmentMail.Move(AppointmentFolder);
            var folderName = "Appointment Folder";

            Log.Information($"Move appointment:{appointmentMail.Subject} to {folderName}.");
        }
コード例 #2
0
        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);
            }
        }