/// <summary> /// Stop this archiver if it is active and is configured to be inactive. /// </summary> /// <param name="archiver">The archiver to stop.</param> private void StopSynchroniserIfUnconfigured(EmailArchiving archiver) { if (archiver != null && Settings.Default.AutoArchive == false && archiver.IsActive) { archiver.Stop(); } }
/// <summary> /// Start this archiver process, if it is configured to run, /// provided it is not already running. /// </summary> /// <param name="archiver">The archiver to start.</param> private void StartSynchroniserIfConfigured(EmailArchiving archiver) { if (archiver != null && Settings.Default.AutoArchive == true && !archiver.IsActive) { DoOrLogError(() => archiver.Start(), catalogue.GetString("Starting {0}", new object[] { archiver.GetType().Name })); } }
private void btnArchive_Click(object sender, EventArgs e) { try { if (this.tsResults.Nodes.Count == 0) { MessageBox.Show("There are no search results.", "Error"); return; } var selectedCrmEntities = GetSelectedCrmEntities(this.tsResults); if (!selectedCrmEntities.Any()) { MessageBox.Show("No selected CRM entities", "Error"); return; } var selectedEmailsCount = Globals.ThisAddIn.SelectedEmailCount; if (selectedEmailsCount == 0) { MessageBox.Show("No emails selected", "Error"); return; } List <ArchiveResult> emailArchiveResults; using (WaitCursor.For(this, disableForm: true)) { var archiver = new EmailArchiving(); emailArchiveResults = Globals.ThisAddIn.SelectedEmails .Select(mailItem => archiver.ArchiveEmailWithEntityRelationships(mailItem, selectedCrmEntities, this.type)) .ToList(); } if (ReportOnEmailArchiveSuccess(emailArchiveResults)) { Close(); } } catch (System.Exception exception) { Log.Error("btnArchive_Click", exception); MessageBox.Show("There was an error while archiving", "Error"); } }
/// <summary> /// Prepare me for running. /// </summary> private void Prepare() { var outlookApp = this.Application; this.MaybeUpgradeSettings(); OutlookVersion = (OutlookMajorVersion)Convert.ToInt32(outlookApp.Version.Split('.')[0]); StartLogging(); synchronisationContext = new SyncContext(outlookApp); contactSynchroniser = new ContactSyncing("CS", synchronisationContext); taskSynchroniser = new TaskSyncing("TS", synchronisationContext); appointmentSynchroniser = new AppointmentSyncing("AS", synchronisationContext); EmailArchiver = new EmailArchiving("EM", synchronisationContext.Log); var outlookExplorer = outlookApp.ActiveExplorer(); this.objExplorer = outlookExplorer; outlookExplorer.FolderSwitch -= objExplorer_FolderSwitch; outlookExplorer.FolderSwitch += objExplorer_FolderSwitch; // TODO: install/remove these event handlers when settings.AutoArchive changes: outlookApp.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.Application_NewMail); outlookApp.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(this.Application_ItemSend); ((Outlook.ApplicationEvents_11_Event)Application).Quit += new Outlook.ApplicationEvents_11_QuitEventHandler(ThisAddIn_Quit); if (OutlookVersion < OutlookMajorVersion.Outlook2010) { outlookApp.ItemContextMenuDisplay += new Outlook.ApplicationEvents_11_ItemContextMenuDisplayEventHandler(this.Application_ItemContextMenuDisplay); var menuBar = outlookExplorer.CommandBars.ActiveMenuBar; objSuiteCRMMenuBar2007 = (Office.CommandBarPopup)menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, true); if (objSuiteCRMMenuBar2007 != null) { ConstructOutlook2007MenuBar(); } } else { //For Outlook version 2010 and greater //var app = this.Application; //app.FolderContextMenuDisplay += new Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHander(this.app_FolderContextMenuDisplay); } }