none
How to change font size and color on the subject line of an email in inbox folder? RRS feed

  • Question

  • Hi, Guys,

    I am developing a plugin for outlook 2016. I have to change font size and color on the subject line of an email in inbox folder.

    I am using C# and Visual Studio 2016 to interact with Outlook COM dll to configure the Outlook 2016. So far, I haven't found any way to change the font color, size, etc for the subject line of any email in inbox folder. Every email in inbox occupies a line. I have to assign different colors and font sizes to each email based on their senders.

    Is this task doable? Can anybody give me any advice?

    Thanks,

    Michael

    Wednesday, July 18, 2018 11:42 PM

Answers

  • The best you can do is apply conditional formatting based on some message criteria. Click View | View Settings | Conditional Formatting.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Proposed as answer by Terry Xu - MSFT Thursday, July 19, 2018 1:48 AM
    • Marked as answer by mxz9102 Wednesday, August 1, 2018 8:17 PM
    Wednesday, July 18, 2018 11:44 PM
  • Hello Michael,

    Looks like you need to customize the current view in Outlook. The AutoFormatRule object represents a formatting rule used by a View object to determine how to format Outlook items displayed within that view. 

    Use the Add method or the Insert method of the AutoFormatRules collection to create a new formatting rule for the following objects:

    Microsoft Outlook provides a set of built-in formatting rules that can be disabled but cannot be removed or reordered. Custom formatting rules, defined either programmatically or by user action, cannot be moved above or between built-in formatting rules. Use the Standard property to determine whether a formatting rule is built-in or custom.

    Formatting rules are checked and applied against each Outlook item, in the order in which they are contained within the AutoFormatRules collection. Use the Enabled property to enable or disable a formatting rule, the Filter property to define the conditions an Outlook item must meet to be formatted by the formatting rule, and the Font property to specify the format to be applied by the formatting rule.

    Conditional formatting is stored in the data store as a hidden item. It's not part of View.XML, it's stored separately. It will persist between Outlook sessions as long as a named view is set with the formatting, if a default view is set up with conditional formatting it likely won't survive between sessions. So, in that scenario the conditional formatting is not stored between sessions. You need to re-apply it each time Outlook starts.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Marked as answer by mxz9102 Wednesday, August 1, 2018 8:17 PM
    Thursday, July 19, 2018 3:24 PM

All replies

  • The best you can do is apply conditional formatting based on some message criteria. Click View | View Settings | Conditional Formatting.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Proposed as answer by Terry Xu - MSFT Thursday, July 19, 2018 1:48 AM
    • Marked as answer by mxz9102 Wednesday, August 1, 2018 8:17 PM
    Wednesday, July 18, 2018 11:44 PM
  • Hello Michael,

    Looks like you need to customize the current view in Outlook. The AutoFormatRule object represents a formatting rule used by a View object to determine how to format Outlook items displayed within that view. 

    Use the Add method or the Insert method of the AutoFormatRules collection to create a new formatting rule for the following objects:

    Microsoft Outlook provides a set of built-in formatting rules that can be disabled but cannot be removed or reordered. Custom formatting rules, defined either programmatically or by user action, cannot be moved above or between built-in formatting rules. Use the Standard property to determine whether a formatting rule is built-in or custom.

    Formatting rules are checked and applied against each Outlook item, in the order in which they are contained within the AutoFormatRules collection. Use the Enabled property to enable or disable a formatting rule, the Filter property to define the conditions an Outlook item must meet to be formatted by the formatting rule, and the Font property to specify the format to be applied by the formatting rule.

    Conditional formatting is stored in the data store as a hidden item. It's not part of View.XML, it's stored separately. It will persist between Outlook sessions as long as a named view is set with the formatting, if a default view is set up with conditional formatting it likely won't survive between sessions. So, in that scenario the conditional formatting is not stored between sessions. You need to re-apply it each time Outlook starts.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Marked as answer by mxz9102 Wednesday, August 1, 2018 8:17 PM
    Thursday, July 19, 2018 3:24 PM
  • Thanks. Terry,

    I am able to add the rule manually in Outlook2016. However, I need to do it in C# programmatically. Do you have any sample code that completes similar functions?

    Thursday, July 19, 2018 5:20 PM
  • Hi, Eugene,

    Thanks a lot for your information. I have made the following code to change font color to blue if subject of an email in Inbox folder contains Apple. However, the rule can be created and saved. But it was not applied to Outlook 2016. I have read a few posts and found this is an Outlook bug and Microsoft won't fix it. Is this still a bug?

    Here is the link.

    https://stackoverflow.com/questions/48223537/outlook-vsto-add-in-autoformatrule-filter-is-not-applied

    Here is my code.

    Outlook.TableView view =
    (Outlook.TableView)this.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox).CurrentView;
    Outlook.AutoFormatRule rule = view.AutoFormatRules.Add("test");
    rule.Font.Color = Outlook.OlColor.olColorBlue;
    rule.Filter = "urn:schemas:httpmail:subject LIKE '%Apple%'";
    rule.Enabled = true;
    view.AutoFormatRules.Save();
    view.Save();
    view.Apply();

    Thursday, July 19, 2018 5:24 PM