public static void AddCategory(String tagName, Outlook.Application application) { Outlook.Categories categories = application.Session.Categories; if (!CategoryExists(tagName, application)) { Outlook.Category category = categories.Add(tagName); } }
private static void AddACategory(string categoryName, Outlook.OlCategoryColor color) { Outlook.Categories categories = ThisAddIn.zmiennaDoSettinngs.Session.Categories; if (!CategoryExists(categoryName)) { _ = categories.Add(categoryName, color); } }
private void AddACategory() { Outlook.Categories categories = Application.Session.Categories; if (!CategoryExists("Onbekend mail adress")) { Outlook.Category category = categories.Add("Onbekend mail adress", Outlook.OlCategoryColor.olCategoryColorDarkRed); } if (!CategoryExists("none")) { Outlook.Category category = categories.Add("none", Outlook.OlCategoryColor.olCategoryColorNone); } if (!CategoryExists("Automatisch gearchiveerd")) { Outlook.Category category = categories.Add("Automatisch gearchiveerd", Outlook.OlCategoryColor.olCategoryColorGreen); } }
/// <summary> /// Update Outlook master category set based on CategoryName /// </summary> /// <param name="CategoryName"></param> /// <returns></returns> public string UpdateCategory(string CategoryName) { for (int i = 0; i < _Category.Count; i++) { if (string.Equals(_Category[i + 1].Name, CategoryName)) { return(CategoryName); } } LoggerProvider.Instance.Logger.Debug("Add new category {0}"); _Category.Add(CategoryName); return(CategoryName); }
private void AddACategory() { Outlook.Categories categories = Application.Session.Categories; string categorie = Localisation.getInstance().getString( Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName, "ARCHIVED_CATEGORY" ); if (!CategoryExists(categorie)) { Outlook.Category category = categories.Add(categorie, Outlook.OlCategoryColor.olCategoryColorGreen); } }
/// <summary> /// Get the Outlook category name for a given category colour. /// If category not yet used, new one added of the form "OGCS [colour]" /// </summary> /// <param name="olCategory">The Outlook category to search by</param> /// <param name="categoryName">Optional: The Outlook category name to also search by</param> /// <returns>The matching category name</returns> public String FindName(Outlook.OlCategoryColor olCategory, String categoryName = null) { if (olCategory == Outlook.OlCategoryColor.olCategoryColorNone) { return(""); } Outlook.Category failSafeCategory = null; foreach (Outlook.Category category in this.categories) { if (category.Color == olCategory) { if (categoryName == null) { if (category.Name.StartsWith("OGCS ")) { return(category.Name); } } else { if (category.Name == categoryName) { return(category.Name); } if (category.Name.StartsWith("OGCS ")) { failSafeCategory = category; } } } } if (failSafeCategory != null) { log.Warn("Failed to find Outlook category " + olCategory.ToString() + " with name '" + categoryName + "'"); log.Debug("Using category with name \"" + failSafeCategory.Name + "\" instead."); return(failSafeCategory.Name); } log.Debug("Did not find Outlook category " + olCategory.ToString() + (categoryName == null ? "" : " \"" + categoryName + "\"")); Outlook.Category newCategory = categories.Add("OGCS " + FriendlyCategoryName(olCategory), olCategory); log.Info("Added new Outlook category \"" + newCategory.Name + "\" for " + newCategory.Color.ToString()); return(newCategory.Name); }
private static void AddACategory() { string[] lines = File.ReadAllLines(@"C:\CategoryList.txt"); var app = new Application(); foreach (string line in lines) { string[] LineArray = line.Split('|'); var color = LineArray[1]; Outlook.Categories categories = app.Session.Categories; //Add categories if (CategoryExists(LineArray[0], app) == false) { categories.Add(LineArray[0], color); } } }
/// <summary> /// Get the Outlook category name for a given category colour. /// If category not yet used, new one added of the form "OGCS [colour]" /// </summary> /// <param name="olCategory">The Outlook category to search by</param> /// <returns>The matching category name</returns> public String FindName(Outlook.OlCategoryColor olCategory) { if (olCategory == Outlook.OlCategoryColor.olCategoryColorNone) { return(""); } foreach (Outlook.Category category in this.categories) { if (category.Color == olCategory && category.Name.StartsWith("OGCS ")) { return(category.Name); } } Outlook.Category newCategory = categories.Add("OGCS " + FriendlyCategoryName(olCategory), olCategory); return(newCategory.Name); }
private void InitializeCategoryGallery() { galleryCategory.Items.Clear(); Outlook.Categories categories = Globals.ThisAddIn.Application.ActiveExplorer().Session.Categories; // ensure we have a "WFM for Outlook" category to tag try { if (categories[Options.CONFIG_MESSAGE_SUBJECT] == null) { Outlook.Category wfmCategory = categories.Add(Options.CONFIG_MESSAGE_SUBJECT, Outlook.OlCategoryColor.olCategoryColorYellow); } } catch (Exception e) { MessageBox.Show($"Failed to initialize a default category: {e}"); } var dropdownItem = this.Factory.CreateRibbonDropDownItem(); dropdownItem.Label = "None"; dropdownItem.Tag = string.Empty; galleryCategory.Items.Clear(); galleryCategory.Items.Add(dropdownItem); galleryCategory.SelectedItem = dropdownItem; foreach (Outlook.Category cat in categories) { dropdownItem = this.Factory.CreateRibbonDropDownItem(); dropdownItem.Label = cat.Name; dropdownItem.Tag = cat.CategoryID; galleryCategory.Items.Add(dropdownItem); if (Globals.ThisAddIn.userOptions.categoryName == cat.Name) { galleryCategory.SelectedItem = dropdownItem; } } }
/// <summary> /// Get the Outlook category name for a given category colour. /// If category not yet used, new one added of the form "OGCS [colour]" /// </summary> /// <param name="olCategory">The Outlook category to search by</param> /// <param name="categoryName">Optional: The Outlook category name to also search by</param> /// <param name="createMissingCategory">Optional: Create unused category colour?</param> /// <returns>The matching category name</returns> public String FindName(Outlook.OlCategoryColor?olCategory, String categoryName = null, Boolean createMissingCategory = true) { if (olCategory == null || olCategory == Outlook.OlCategoryColor.olCategoryColorNone) { return(""); } Outlook.Category failSafeCategory = null; foreach (Outlook.Category category in this.categories) { try { if (category.Color == olCategory) { if (categoryName == null) { if (category.Name.StartsWith("OGCS ")) { return(category.Name); } else if (!createMissingCategory) { return(category.Name); } } else { if (category.Name == categoryName) { return(category.Name); } if (category.Name.StartsWith("OGCS ")) { failSafeCategory = category; } } } } catch (System.Runtime.InteropServices.COMException ex) { if (OGCSexception.GetErrorCode(ex, 0x0000FFFF) == "0x00004005") //The operation failed. { log.Warn("It seems a category has been manually removed in Outlook."); OutlookOgcs.Calendar.Instance.IOutlook.RefreshCategories(); } else { throw; } } } if (failSafeCategory != null) { log.Warn("Failed to find Outlook category " + olCategory.ToString() + " with name '" + categoryName + "'"); log.Debug("Using category with name \"" + failSafeCategory.Name + "\" instead."); return(failSafeCategory.Name); } log.Debug("Did not find Outlook category " + olCategory.ToString() + (categoryName == null ? "" : " \"" + categoryName + "\"")); String newCategoryName = "OGCS " + FriendlyCategoryName(olCategory); if (!createMissingCategory) { createMissingCategory = System.Windows.Forms.OgcsMessageBox.Show("There is no matching Outlook category.\r\nWould you like to create one of the form '" + newCategoryName + "'?", "Create new Outlook category?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes; } if (createMissingCategory) { Outlook.Category newCategory = categories.Add(newCategoryName, olCategory); log.Info("Added new Outlook category \"" + newCategory.Name + "\" for " + newCategory.Color.ToString()); return(newCategory.Name); } return(""); }