Adding an internet header flag via graph api seems to change more in the email than expected

geetarman 26 Reputation points

I have a background service which cycles through specific users emails and processes them then uses an internet header flag to mark it as processed.
I have the following code which adds/updates the custom internet header flag in a users email using the graph api. I am then comparing the emails by saving an eml copy.

    public const string PS_INTERNET_HEADERS_STRING = "String {00020386-0000-0000-C000-000000000046} Name ";  
    public const string ExtendedPropertyPrefix = "X-INVU-";  
    public async Task<bool> SetFlag(object msgId, bool bUid, string flagName, int value)  
        // Create an item that is used to provision the custom x-header.  
    var user = await FindUser();  

        var flagIdentity = $"{PS_INTERNET_HEADERS_STRING}{ExtendedPropertyPrefix}{flagName}";  
        var message = await user.Messages[(string)msgId].Request().Select(a => new { a.SingleValueExtendedProperties }).Expand($"singleValueExtendedProperties($filter=id eq '{flagIdentity}')").GetAsync();  
        if (message.SingleValueExtendedProperties == null)  
            message.SingleValueExtendedProperties = new MessageSingleValueExtendedPropertiesCollectionPage();  

        foreach (var s in message.SingleValueExtendedProperties)  
            if (s.Id == flagIdentity)  
                s.Value = value.ToString();  
        var prop = new SingleValueLegacyExtendedProperty  
            Id = flagIdentity,  
            Value = value.ToString()  
        await user.Messages[(string)msgId].Request().Select(a => a.SingleValueExtendedProperties).UpdateAsync(message);  
        return true;  

and to save the eml file for comparison

   public bool SaveEml(string path)  
        var content = _service.Users[_userId].Messages[(string)_emailId.Id].Content.Request().GetAsync().Result;  
        using (var fileStream = System.IO.File.Open(path, FileMode.Create, FileAccess.Write))  
            var buffer = new byte[1000];  
            int read;  
            while ((read = content.Read(buffer, 0, 1000)) > 0)  
        return true;  

This code works but it seems to change a lot more in the email when it adds the flag for the first time.
If I compare an eml file saved after the flag is added there are a lot of changes I don't understand but the primary one is that the content-transfer-encoding has changed from quoted-printable to base64'. I also noted that an inline png attachment appears to have changed in size. (example differences are attached produced using notepad++)

If the flag is then subsequently changed then a comparison of the email before and after shows only one change (the value of the flag).

Can anyone comment - I was expecting the only difference to be the addition of the flag....

Following are some screenshots of some of the changes mentioned




Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,451 questions
0 comments No comments
{count} votes