public void SetTagBarHelper(TagBarHelper helper) { this.tagBarHelper = helper; }
public static void AddTagToEmail(String tag, Outlook.MailItem mi, Outlook.Application application, TagBarHelper explorerTagBarHelper) { Backend.TagEmail(mi.EntryID, tag); Backend.TagPerson(Utils.NormalizeName(mi.SenderName), tag); CategoryUtils.AddCategoryToMailItem(mi, tag, application); /* The email might be opened in more than one place - the inspector and any number of explorers, so find all the ones * are showing the mailItem and add the tag there. */ AddTagToExplorerEmailIfMatch(mi.EntryID, tag, application, explorerTagBarHelper); foreach (Outlook.Inspector inspector in application.Inspectors) { AddTagToInspectorEmailIfMatch(inspector, mi.EntryID, tag); } }
private static void AddTagToExplorerEmailIfMatch(String entryID, String tag, Outlook.Application application, TagBarHelper exlorerTagBarHelper) { try { if (application.ActiveExplorer().Selection.Count > 0) { Object selObject = application.ActiveExplorer().Selection[1]; if (selObject is Outlook.MailItem) { Outlook.MailItem mailItem = selObject as Outlook.MailItem; if (mailItem.EntryID.Equals(entryID)) { exlorerTagBarHelper.AddNewButton(tag); } } } } catch (Exception ex) { String expMessage = ex.Message; System.Windows.Forms.MessageBox.Show(expMessage); } }
public static void RemoveTagFromEmail(String tag, Outlook.MailItem mi, Outlook.Application application, TagBarHelper explorerTagBarHelper) { Backend.UntagEmail(mi.EntryID, tag); CategoryUtils.RemoveCategoryFromMailITem(tag, mi); /* The email might be opened in more than one place - the inspector and any number of explorers, so find all the ones * are showing the mailItem and remove the tag there. */ RemoveTagFromExplorerEmailIfMatch(mi.EntryID, tag, application, explorerTagBarHelper); foreach (Outlook.Inspector inspector in application.Inspectors) { RemoveTagFromInspectorEmailIfMatch(inspector, mi.EntryID, tag); } }