I am trying to add a Category to an email via Graph. I found this: https://github.com/microsoftgraph/microsoft-graph-docs/blob/main/api-reference/v1.0/resources/outlookcategory.md But it only explains how to create a new category. I already got my categories and I'd like to add one to a mail I've also got in memory.
var categories = await graphService.Users[metadata.UserOid].Outlook.MasterCategories.Request().GetAsync();
var category = categories.SingleOrDefault(c => c.DisplayName == name);
if (category == null)
{
if (KNOWN_OUTLOOK_CATEGORIES.ContainsKey(name))
{
await graphService.Users[metadata.UserOid].Outlook.MasterCategories.Request().AddAsync(KNOWN_OUTLOOK_CATEGORIES[name]);
if (retry > 3)
throw new InvalidOperationException($"Cannot create category in mailbox: {name}.");
await SetCategoryMailByName(name, graphService, metadata, retry + 1);
}
}
// Add my category to the mail
await graphService.Users[metadata.UserOid].Messages[m.MailId].Categories.Add(category);
Problem here is that there is no category in the mail. How could I add one?