emailoutlookmicrosoft-graph-apireply

How to exclude specific Outlook messages from tracking using Microsoft Graph API without breaking the thread?


I’m building a multi-provider email client that tracks sent/replied/forwarded messages. For Gmail, I can easily exclude specific messages from my tracking mechanism by adding a custom header (e.g., X-CRM-IGNORE) when sending/replying/forwarding via Gmail APIs.

Example:

X-CRM-IGNORE: true

This works perfectly and doesn’t break the thread.

However, for Outlook / Microsoft Graph API, I cannot find any way to add custom headers when replying or forwarding messages. Graph allows specifying recipients, body, attachments, etc., but not arbitrary Internet headers.

I need a way to mark certain messages (sent/replied/forwarded via Graph API) so they can be excluded from tracking.

This must not break the conversation/threading in Outlook or Graph.

Ideally, it should behave similar to Gmail’s X-CRM-IGNORE.

Questions:

Is there any way to add custom Internet headers (like X-CRM-IGNORE) when sending, replying, or forwarding messages via Microsoft Graph?

If not, what are the recommended alternatives to mark these messages so I can still identify and skip them later? (e.g., categories, extensions, message properties, etc.)


Solution

  • You can try a singleValueLegacyExtendedProperty for outlook to sent custom key.

    create key when send

     const replyMessage = {
                comment: comment
                message: {
                    singleValueExtendedProperties: [
                        {
                            "id": "String {guid} Name Property-name",
                            "value": "String"
                        }
                    ],
                }
            };
    

    example guid: 66f5a359-4659-4830-9070-00040ec6ac6e

    and on the event side you can fetch with expand.

    const message = await this.graphClient
                    .api(`/me/messages/${messageId}`)
                    .expand("singleValueExtendedProperties($filter=id eq 'String {guid} Name X-CRM-IGNORE')")
                    .get();
    

    Hey here is the resources.

    https://learn.microsoft.com/en-us/graph/api/singlevaluelegacyextendedproperty-post-singlevalueextendedproperties?view=graph-rest-1.0&tabs=javascript