'Getting the wrong attachment id from office.js for self emailed attachments

I have an outlook add-in that is getting a attachmentId and messageId from office.js and from there I use the translate api to translate the ewsId to a restId and then use graph api to fetch the attachment details. This works fine regularly, but when I email an attachment to myself or forward an attachment to myself, the attachmentId I get from office.js cannot be used to find the attachment on graph api.

If instead I use ews then there is not issue.

call to graph api: https://graph.microsoft.com/v1.0/me/messages/{{messageId}}/attachments/{{attachmentId}}

Email "A" from another user
messageId: "AAMkADQ2NDE4MTgwLTc3YWYtNDMyNy1hNzBlLWYwYjFhNDFmOGMyMQBGAAAAAADe8oquh3hHQ4w-IhUlYfScBwBAr1kmfoJuRo_-wLGwaLC2AAAAAAEMAABAr1kmfoJuRo_-wLGwaLC2AAAnJNB1AAA="

attachmentId: "AAMkADQ2NDE4MTgwLTc3YWYtNDMyNy1hNzBlLWYwYjFhNDFmOGMyMQBGAAAAAADe8oquh3hHQ4w-IhUlYfScBwBAr1kmfoJuRo_-wLGwaLC2AAAAAAEMAABAr1kmfoJuRo_-wLGwaLC2AAAnJNB1AAABEgAQADY8gKUKKedKsb_bhRYobps="

If I email, email "A" to myself:
messageId: "AAMkADQ2NDE4MTgwLTc3YWYtNDMyNy1hNzBlLWYwYjFhNDFmOGMyMQBGAAAAAADe8oquh3hHQ4w-IhUlYfScBwBAr1kmfoJuRo_-wLGwaLC2AAAAAAEJAABAr1kmfoJuRo_-wLGwaLC2AABW6oApAAA="

attachmentId: "AAMkADQ2NDE4MTgwLTc3YWYtNDMyNy1hNzBlLWYwYjFhNDFmOGMyMQBGAAAAAADe8oquh3hHQ4w-IhUlYfScBwBAr1kmfoJuRo_-wLGwaLC2AAAAAAEMAABAr1km



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source