@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 “Interface IGraphClient | Aspose.Email for .NET API Reference” 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
@skarlsen,
Unfortunately, in this case, there is no way to update the message category, because there is no relation with a message on the server. You should use our GraphClient
to receive the messages. Then you could use the filled ItemId
to update the message category for the server.
@Andrey_Potapov
The thing which you are suggesting is not what we are looking for, We are creating a outlook email file in the memory using your Email Library in which we want to update the category
Is there any alternative to implement this?
Thank you
@skarlsen
We are sorry for your inconvenience. Can you please share the details of the issue/requirement that what you want API to offer to you. Perhaps a snapshot will be helpful and I will verify that to assist you further.