public ArchiveResult ArchiveEmailWithEntityRelationships(Outlook.MailItem olItem, IEnumerable <CrmEntity> selectedCrmEntities, EmailArchiveReason reason) { var result = olItem.Archive(reason); if (result.IsSuccess) { var warnings = CreateEmailRelationshipsWithEntities(result.EmailId, selectedCrmEntities); result = ArchiveResult.Success( result.EmailId, result.Problems == null ? warnings : result.Problems.Concat(warnings)); } return(result); }
/// <summary> /// Send, and also archive to CRM, the current message in the composer window. /// </summary> /// <param name="control">The ribbon which caused this action to be raised.</param> public void btnSendAndArchive_Action(IRibbonControl control) { Outlook.MailItem olItem = (Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as Outlook.MailItem); if (olItem != null) { if (Globals.ThisAddIn.HasCrmUserSession) { try { try { olItem.Archive(EmailArchiveReason.SendAndArchive); } catch (Exception failedToArchve) { Globals.ThisAddIn.ShowAndLogError( failedToArchve, $"Failed to archive message because {failedToArchve.Message}", "Failed to archive"); } olItem.Send(); } catch (Exception failedToSend) { Globals.ThisAddIn.ShowAndLogError( failedToSend, $"Failed to send message because {failedToSend.Message}", "Failed to send"); } } else { ShowNoSessionWarning(); } } else { Globals.ThisAddIn.Log.AddEntry( "No message while attempting to send and archive?", LogEntryType.Warning); } }
public void ProcessEligibleNewMailItem(Outlook.MailItem olItem, EmailArchiveReason reason, string excludedEmails = "") { var parentFolder = olItem.Parent as Outlook.Folder; if (parentFolder == null) { Log.Debug($"NULL email folder for {reason} “{olItem.Subject}”"); return; } if (EmailShouldBeArchived(reason, parentFolder.Store)) { olItem.Archive(reason, excludedEmails); } else { Log.Debug($"NOT archiving {reason} email (folder {parentFolder.Name})"); } }
public ArchiveResult ArchiveEmailWithEntityRelationships(Outlook.MailItem olItem, IEnumerable <CrmEntity> selectedCrmEntities, EmailArchiveReason reason) { return(olItem.Archive(reason, selectedCrmEntities)); }