Пример #1
0
        public override void ProcessBeforeItemMove(object item, object moveTo, AddinExpress.MSO.ADXCancelEventArgs e)
        {
            if (item is Outlook._ContactItem)
            {
                Outlook._ContactItem movedContact = (Outlook._ContactItem)item;
                Outlook._Application outlookApp   = ((AddinModule)this.Module).OutlookApp;
                Outlook._JournalItem journalItem  = null;

                try
                {
                    journalItem = (Outlook._JournalItem)outlookApp.CreateItem(Outlook.OlItemType.olJournalItem);
                    if (moveTo != null)
                    {
                        Outlook.MAPIFolder targetFolder = (Outlook.MAPIFolder)moveTo;
                        journalItem.Subject = String.Format("You've moved {0} to {1}",
                                                            movedContact.FullName, targetFolder.FolderPath);
                        Marshal.ReleaseComObject(moveTo);
                    }
                    else
                    {
                        journalItem.Subject = String.Format("You've permanently deleted {0}",
                                                            movedContact.FullName);
                    }
                    journalItem.Save();
                }
                finally
                {
                    if (journalItem != null)
                    {
                        Marshal.ReleaseComObject(journalItem);
                    }
                }
            }
        }
Пример #2
0
        public override void ProcessBeforeFolderMove(object moveTo, AddinExpress.MSO.ADXCancelEventArgs e)
        {
            if (this.FolderObj != null)
            {
                Outlook._Application outlookApp  = ((AddinModule)this.Module).OutlookApp;
                Outlook._JournalItem journalItem = null;

                try
                {
                    journalItem = (Outlook._JournalItem)outlookApp.CreateItem(Outlook.OlItemType.olJournalItem);
                    if (moveTo != null)
                    {
                        Outlook.MAPIFolder targetFolder = (Outlook.MAPIFolder)moveTo;
                        journalItem.Subject = String.Format("You've moved the folder to {1}",
                                                            targetFolder.FolderPath);
                    }
                    else
                    {
                        Outlook.MAPIFolder deletedFolder = (Outlook.MAPIFolder) this.FolderObj;
                        journalItem.Subject = String.Format("You've permanently deleted {0}",
                                                            deletedFolder.FolderPath);
                    }
                }
                finally
                {
                    if (journalItem != null)
                    {
                        Marshal.ReleaseComObject(journalItem);
                    }
                }
            }
        }