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

Free Support Forum - aspose.com

Updating the message category in Outlook

For updating the category in Outlook is there any API available in Aspose.Email which we can use to update Category in Outlook ? and if not while parsing email using MAPI class we are getting itemID as null MAPIItemID.PNG (1.3 KB)

For parsing email file we are using this piece of code. EmailParser.zip (464.6 KB)

@skarlsen,
Thank you for the issue descriptions.

I reproduced the problem and received the same results. I have logged the issue in our tracking system with ID EMAILNET-40135 for further investigation. You will be notified when it is fixed.

Could you please describe more details about your requirements for updating the categories?

We need to update the category in Outlook email as shown in attachment.

MicrosoftTeams-image.png (20.8 KB)

@skarlsen,
You can update the categories in MSG files as below:

MapiMessage msg = MapiMessage.FromFile(msgFilePath);
// add category
FollowUpManager.AddCategory(msg, "Red Category");
// remove category
FollowUpManager.RemoveCategory(msg, "Red Category");

More details: Setting Color Category for Outlook MSG Files
API Reference: FollowUpManager Class

I want to update the existing email in Outlook with category when that email file is send to our ASP.Net Web API where we are using Aspose.Email package.

So we need something that can update the category of email in Outlook server not in the MapiMessage class object.

Hope this is clear to you regarding our requirement.

@skarlsen,
Thank you for the additional information. It will take me some time to answer your questions.

@skarlsen,
I’m sorry, you should clarify what do you mean by “Outlook server”? Does it mean Outlook365?

Yes, So we can update existing emails category when those emails are send to our Web API in which we are using Aspose Email package

@skarlsen,
You can try to use IGraphClient interface for your purposes as below:

// client is IGraphClient instance
OutlookCategory updatedCategory = client.UpdateCategory(category);

API Reference: IGraphClient Interface
Note: GraphClient class is a relatively new component in Aspose.Email.

This is a custom property that is used to manipulate message objects on the server. That files do not contain this property, so it is null.

Could you please provide if there is any documentation to refer for initialise the “IGraphClient client” object?

We had refered this “https://apireference.aspose.com/email/net/aspose.email.clients.graph/igraphclient” document available on Aspose but didn’t find anything on how we can initialise “IGraphClient client”.

@skarlsen

I have made a working sample project using MS Graph that is initializing the client and then accessing the emails and also sending email. Can you please try this by setting your credentials and share if there is still an issue.

TestMSGraph.zip (4.1 MB)

@mudassir.fayyaz

We have tried using the Graph client that you provided us earlier to update Category of Email in Outlook, but that API is giving “Object reference not set to an instance of an object” error.

Attached here is the code of our Web API which accepts an email as HttpPostedFile and converts it into MapiMessage object.
TestWebAPI.zip (30.5 KB)

Below are the sample email file used for testing,

EmailFiles.zip (46.7 KB)

You can see ItemId property is “null”:
ItemId.jpg (72.1 KB)

Can you please check the sample code we have used in Web API and guide us how we can update the category of Email in Outlook?

Thanks,
Stig

@skarlsen

I have observed the issue shared by you and we need to investigate this further on our end. A ticket with ID EMAILNET-40147 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.

Hello,

Any progress for the issue we addressed while Updating the category in Outlook using the Aspose.Email.Clients.Graph class.

Thank you.

@skarlsen

I regret to share that at present the issue is still unresolved. We request for your patience and likely the issue gets fixed in upcoming version of Aspose.Email for .NET. We will share notification with you once it will be fixed.

The issues you have found earlier (filed as EMAILNET-40147) have been fixed in this update.

Hello,

I have checked with the updated version of the Aspose Email Package i.e 21.3.0 and still getting the ItemId as null.ItemId.PNG (8.0 KB)
And we are using the code EmailParser.zip (475.6 KB)

Can you please guide us how can we get the ItemId from the outlook message file?

Thank you

@skarlsen,
The ItemId property is filled by the server and is required for further message processing. You can receive and process the message as shown below:

FolderInfoCollection folderInfoCol1 = graphClient.ListFolders();
FolderInfo inbox = null;
foreach (FolderInfo folderInfo in folderInfoCol1)
{
    if (folderInfo.DisplayName.Equals("Inbox", StringComparison.InvariantCultureIgnoreCase))
    {
        inbox = folderInfo;
        break;
    }
}

MessageInfoCollection messageInfoCol = graphClient.ListMessages(inbox.ItemId);

for (int i = messageInfoCol.Count - 1; i >= 0; i--)
{
    MapiMessage message = graphClient.FetchMessage(messageInfoCol[i].ItemId);
    message.Subject = "new subject";
    message.Body = "new body";
    MapiMessage updmsg = graphClient.UpdateMessage(message);
}

More examples: How to use GraphClient for Microsoft Graph

@Andrey_Potapov
From the above code we understood that , you are retrieving all the messages from the inbox folder from outlook and updating the subject/category.
But in our case we already have a message file for which we want to update the category and for that ItemId is required which is getting as null.
Is there any possibility of updating the existing message file?

Thank you