admin管理员组

文章数量:1279042

I've done a great deal of googling, stack searching, and I cannot seem to find a way to update/patch an item using Graph API (specifically attempting to update an email message) to remove a MultiValueExtendeProperty. With EWS there was a function "RemoveExtendedProperty" from the object. With Graph API, I cannot seem to find a way to "delete", "clear" or otherwise remove the MultiValueExtendedProperty(s). Does anyone know of a way to leverage Graph API as we have to switch off EWS due to their login system changing.

Example Snippet

var gmc = new GraphMailClient(auth);

var account = "[email protected]";
var idval = "somemessageidyoucanlookupandedit";

var start = await gmc.Users[account].Messages[idval].Request().GetAsync();

start.MultiValueExtendedProperties = new MessageMultiValueExtendedPropertiesCollectionPage()
{
    new MultiValueLegacyExtendedProperty() { Id  = "StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE1", Value = new string[] { "test" } },
    new MultiValueLegacyExtendedProperty() { Id  = "StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2", Value = new string[] { DateTime.Now.AddMinutes(3).ToString() } }
};
var saveDraftId = await gmc.SaveDraftAsync(account, start);
var entry = await gmc.Users[account].Messages[idval].Request().Expand("multiValueExtendedProperties($filter = id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE1' or id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2'), attachments").GetAsync();

entry.MultiValueExtendedProperties.RemoveAt(0);
entry.MultiValueExtendedProperties.Clear();

var result = await gmc.Users[account].Messages[idval].Request().Expand("multiValueExtendedProperties($filter = id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE1' or id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2'), attachments").UpdateAsync(entry);
var entryAgain = await gmc.Users[account].Messages[idval].Request().Expand("multiValueExtendedProperties($filter = id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE1' or id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2'), attachments").GetAsync(); 

if(entryAgain.MultiValueExtendedProperties.Any())
    Console.WriteLine("Failed");

Thanks

I've done a great deal of googling, stack searching, and I cannot seem to find a way to update/patch an item using Graph API (specifically attempting to update an email message) to remove a MultiValueExtendeProperty. With EWS there was a function "RemoveExtendedProperty" from the object. With Graph API, I cannot seem to find a way to "delete", "clear" or otherwise remove the MultiValueExtendedProperty(s). Does anyone know of a way to leverage Graph API as we have to switch off EWS due to their login system changing.

Example Snippet

var gmc = new GraphMailClient(auth);

var account = "[email protected]";
var idval = "somemessageidyoucanlookupandedit";

var start = await gmc.Users[account].Messages[idval].Request().GetAsync();

start.MultiValueExtendedProperties = new MessageMultiValueExtendedPropertiesCollectionPage()
{
    new MultiValueLegacyExtendedProperty() { Id  = "StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE1", Value = new string[] { "test" } },
    new MultiValueLegacyExtendedProperty() { Id  = "StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2", Value = new string[] { DateTime.Now.AddMinutes(3).ToString() } }
};
var saveDraftId = await gmc.SaveDraftAsync(account, start);
var entry = await gmc.Users[account].Messages[idval].Request().Expand("multiValueExtendedProperties($filter = id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE1' or id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2'), attachments").GetAsync();

entry.MultiValueExtendedProperties.RemoveAt(0);
entry.MultiValueExtendedProperties.Clear();

var result = await gmc.Users[account].Messages[idval].Request().Expand("multiValueExtendedProperties($filter = id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE1' or id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2'), attachments").UpdateAsync(entry);
var entryAgain = await gmc.Users[account].Messages[idval].Request().Expand("multiValueExtendedProperties($filter = id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE1' or id eq 'StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2'), attachments").GetAsync(); 

if(entryAgain.MultiValueExtendedProperties.Any())
    Console.WriteLine("Failed");

Thanks

Share Improve this question asked Feb 24 at 2:15 ChrisChris 294 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

To remove the MultiValueExtendedProperty property, send PATCH request, but leave the value of the MultiValueExtendedProperty property empty.

var message = new Message
{
    MultiValueExtendedProperties = new MessageMultiValueExtendedPropertiesCollectionPage()
    {
        new MultiValueLegacyExtendedProperty() { Id  = "StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name MVE2", Value = new string[] { } }
    }
};
var result = await gmc.Users[account].Messages[idval].Request().UpdateAsync(message);

本文标签: Graph API Clear MultiValueExtendedPropertiesStack Overflow