When I create a draft to reply to an email using createReply, the previous attachments get added to the new email

Sacha Baniassad 0 Reputation points
2024-08-04T07:47:13.4466667+00:00

Hello,

I am using the Microsoft Graph API to manage emails.

Here's how my flow looks like to reply to an email:

  1. First, I create a draft to reply to an existing email message (which i specify with {message_id}):
"https://graph.microsoft.com/v1.0/users/{user}/messages/{message_id}/createReply"
  1. Then, I send the reply draft using this endpoint:
"https://graph.microsoft.com/v1.0/users/{user}/messages/{draft_id}/send"

I am having an issue where if the email that I am replying to has any inline attachments, my new email (the reply email) gets those attachments as well (even if i do not specify any attachments for my new message). Note that this is only for inline attachments, and not "normal attachments."

In other words, the attachments of the email that I am replying to get appended onto the new email.

I noticed that this happens immediately after step 1, after I initially create the draft but before I send it.

Here is what my payload looks like for the createReply endpoint (step 1):

reply_data = {
    "message": {
        "subject": subject,
        "body": {
            "contentType": "HTML",
            "content": html_body
        },
        "toRecipients": [
            {
                "emailAddress": {
                    "address": recipient_email
                }
            }
        ],
        "from": {
            "emailAddress": {
                "address": AzureEmail.SENDER_SUPPORT_ALIAS_EMAIL_ADDRESS
            }
        },
        "attachments": []
    },
}

Please note that even despite having an empty array for attachments, they still get included in the reply email. I've also noticed that if I include attachments in my attachments array, they get included in my response, in addition to the attachments from the original email that I am replying to. The attachments get concatenated. Why could this be?

Microsoft Security | Microsoft Graph

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.