We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Category Color

Hello,
You’ve got a code sample to retrieve category color from mapi items?
This one:
Untitled2.png (10.1 KB)
Best

@australian.dev.nerds

A ticket EMAILNET-40844 has been logged for your requirement. We will inform you once there is an update available on it.

Hello,
While searching the docs, I’ve found these 2:
FollowUpManager.GetCategories(MapiMessage)
vs
MapiMessage.Categories
Seems both do the same thing with just different return string types.
Other than that, are those 2 both the same to get the MAPI Item’s category color?

And those will only return colors or other things might be returned as well?

The problem: Both will return the strings, the user might create a new color category named “Blah Color” and assign a color to it!
GetCategories and Categories will return “Blah Color” as string to me!
Also possible to make one named Black category and assign DarkGray to it!
What shall I do with this string? need the color code too, possible to get the color as RGB,Hex etc?

See here:

see enum CategoryColor

Best :slight_smile:

@australian.dev.nerds

Please use the FollowUpManager. This class provides the ability to set and handle follow-up Outlook flags and categories.

You can use following code example to get the list of categories:

var msg = MapiMessage.Load("withCategories.msg"); 
var categoryList = FollowUpManager.GetCategories(msg); 
foreach (var category in categoryList) 
{ 
 Console.WriteLine(category); 
}

You can use following code snippet to get categories as string separated by semicolons (;):

var msg = MapiMessage.Load("withCategories.msg"); 
var opt = FollowUpManager.GetOptions(msg); 
Console.WriteLine(opt.Categories);

Hello,
Yes, already tested, anyway, that only returns the category label, and not the category color
3 links mentioned in my yesterday’s post which seems to be related to the color property
Any idea how to get the color of the category?
Total of 25 colors + 1 empty color exist

  • To get the color, can’t rely on the label as user can name it anything!
    Thanks :slight_smile:

@australian.dev.nerds

We have logged a ticket as EMAILNET-40852 in our issue tracking system to get the color of category of message. We will inform you once there is an update available on it.

1 Like

@australian.dev.nerds

We have closed the ticket EMAILNET-40852 with Won't Fix resolution.

Unfortunately, we can only get a string representation of the category. The color information of a category is not kept in the MSG file.

It looks like a category color is stored in a local Outlook configuration. Please create a msg file with custom categories in Outlook on one computer and then try to open the same file in Outlook on another computer. You will see that color of the categories has been lost.

Hello,
I’m extracting the items from pst/ost, categories are stored in a hidden message with the message class of "IPM.Configuration.CategoryList" in the store’s Calendar folder. Unfortunately the sdk does not allow me to see the hidden messages/objects! Please advise how to get the hidden items so can access that?

Hello, @australian.dev.nerds

categories are stored in a hidden message with the message class of "IPM.Configuration.CategoryList" in the store’s Calendar folder

Thank you for the helpful info :slight_smile: . Yes, it is really true.

You can use the GetContents method, with the MessageKind.FolderAssociatedInformation parameter, to read such configuration items.

I wrote a sample code that looks for IPM.Configuration.CategoryList items.
It seems strange that the information about categories that can be used by any type of message is always in the Calendar folder :slight_smile:
Next, I saved the value of the PidTagRoamingXmlStream property in the .xml file and was able to see the information.

string fileName = "my.ost";

using (var pst = PersonalStorage.FromFile(fileName))
{
    var messages = new List<MapiMessage>();

    ExtractCategoryFromFai(pst, pst.RootFolder, messages);

    var categoriesInfoProperty = messages[0].Properties[KnownPropertyList.RoamingXmlStream];

    System.IO.File.WriteAllBytes("categories.xml", categoriesInfoProperty.Data);
}

Function to search categories info:

public static void ExtractCategoryFromFai(PersonalStorage pst, FolderInfo folder, IList<MapiMessage> messages)
{
    var contents = folder.GetContents(MessageKind.FolderAssociatedInformation);

    foreach (var msgInfo in contents)
    {
        if (msgInfo.MessageClass.Equals("IPM.Configuration.CategoryList"))
        {
            var msg = pst.ExtractMessage(msgInfo);
            messages.Add(msg);
        }
    }

    foreach (var folderInfo in folder.EnumerateFolders())
    {
        ExtractCategoryFromFai(pst, folderInfo, messages);
    }
}
1 Like

Hello and thanks for the help, I will test the code, btw, cannot find the “ExtractCategoryFromFai” function.
I’m going to believe that some functions/properties are hidden or not accessible! This is the 3rd/4th one I think :smiley:

Hello, @australian.dev.nerds

Sorry, but there has never been an ExtractCategoryFromFai function in the Aspose.Email API.
The code for ExtractCategoryFromFai is also in my post above. This function is to find information about categories and check the following:

categories are stored in a hidden message with the message class of “IPM.Configuration.CategoryList” in the store’s Calendar folder

Also, that code sample is the answer to your question

Please advise how to get the hidden items so can access that?

Please check if that code works on your side.
Thanks.

1 Like

Hello and thanks for your sample, I was able to get it working perfectly, just if the category data does not exist in ost/pst it will throw Out Of Range Exception which is notmal:
Untitled.png (32.6 KB)

  1. Still need to find out how to convert ordinal color index no to color RGB/Hex code…

  2. It would be nice to have a built-in function to get the category name + color

  3. This Enum:
    https://reference.aspose.com/email/net/aspose.email.storage.pst/messagekind/
    Why there’s not a third all types one?
    0 Normal
    1 FAI
    2 All Types ( both normal and FAI )

Thanks again :slight_smile:

Hello, @australian.dev.nerds

  1. Still need to find out how to convert ordinal color index no to color RGB/Hex code…
  2. It would be nice to have a built-in function to get the category name + color

So, you need to have the following ready-to-use feature:

  1. A Сolors enum, for all colors supported by Outlook.
  2. A Category class with Name and Color properties.
  3. A PersonalStorage.GetCategories() method which returns an IList<Category> and an empty list if no categories exist.

I think it would not be difficult for devs to implement this, thanks for the info you found :slight_smile:
I think we will just reopen the existing ticket.

Why there’s not a third all types one?
0 Normal
1 FAI
2 All Types ( both normal and FAI )

Please note, MessageKind enum marked with the Flags attribute, so you can call it like this:

var contents = folder.GetContents(MessageKind.Normal | MessageKind.FolderAssociatedInformation);

Thanks.

1 Like

Hello,
I should be thankful for your kind help and valuable code sample, as well as precious support and user hearing.
I will search more for the real color code and will get back to you to implement in the possible function being added.
And an out of topic req, if you’re in charge, please consider adding html, rtf and text txt to the DetectFileFormat function, these extensions all exist in the other SDKs like Words or Cells, but not in the Email, the reason is obvious: These 3 extensions are highly related to the Email bases systems, indeed :slight_smile:

Hello, @australian.dev.nerds

And an out of topic req, if you’re in charge, please consider adding html, rtf and text txt to the
DetectFileFormat function, these extensions all exist in the other SDKs like Words or Cells, but not in the Email, the reason is obvious:

Sure, this will be considered, besides, the ticket has been created since you have already requested this feature in your previous topic.

Thank you.

1 Like

Thanks, and the final verdict is that those colors are not hard-coded anywhere, will render at run-time based on this:


So the category label and color number would be enough, indeed, everything’s clear now :slight_smile:

oh I thought of a way to Try to get the color code for MSG files (although it’s not saved inside)

  1. Check if Outlook is installed?
  2. Look for proper storage file, match the one with the sender email in the MSG file, if found:
  3. Simply parse the said hidden message from pst/ost and get the color codes
  4. Match with the category name inside the MSG and;
  5. According to this table, return the color code:
    https://learn.microsoft.com/en-us/office/vba/api/outlook.olcategorycolor

How’s that? Can be the same or a separate function…

Hello, @australian.dev.nerds

Your algorithm is ok for a custom implementation on the user’s side. But it can’t be implemented as a standalone functionality of Aspose.Email.
The reason is simple, the solution isn’t universal.

  • Aspose.Email is a cross-platform library, so the 1st point makes no sense under Linux platforms.
  • Imagine a user has Outllook installed on two computers. Each Outlook instance has a different category color setting. It will give different results for a same msg.

So, in this case our lib will provide an API for extracting a category name from msg and a color code from ost/pst.

Anyway, thank you very much for your thoughts! You are one of those users who really improve Aspose.Email :slight_smile:

1 Like

oh you’re right, my pov is limited to Windows :slight_smile:
And I guess color code 1 is always Red on any ol instance, if am not wrong.
Finally, yes, it was just a suggestion.

And trying to get the same info from OLM files, first will need to be able to do a deep parse so need to get all folders and files, unfortunately, messagekind does not exist in the olm reader.
If it’s already available, please advise how to read hidden/FAI messages when reading OLM.
If not, please be so kind and add a feature request ticket for OLM::MessageKind
Best :slight_smile:

@australian.dev.nerds

I created the EMAILNET-40862 ticket to implement obtaining category colors from OLM.

please advise how to read hidden/FAI messages when reading OLM

The OLM format is completely differs from the PST/OST format, I doubt it has FAI folders. Unfortunately, its spec is not publicly available. But most likely it has another mechanism for storing global OLM settings. OlmStorage and PersonalStorage have different functionality for the same reason.

Thanks.

1 Like