Problem modifying email message attachments using MS Graph

Rani Rishmawi 1 Reputation point
2021-10-27T07:07:38.437+00:00

Hello experts,

Using MS Graph SDK or MS graph explorer, we are trying to replace an attachment within a message. Updating a message attachment is not supported yet by ms graph API. that's why we do the operation in the following steps:

  1. get the original attachment content.
  2. modify that content.
  3. delete the original attachment.
  4. then add the modified content as a new attachment with the same name.

This works. However, randomly fails, resulting in two attachments the original and the new instead of the message having one updated attachment. the API returns success results in both cases with no indication of what might be the problem.

Here are the calls:

First Request to delete the attachment (step 3):

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

Second Request to add the modified attachment (step 4):

POST https://graph.microsoft.com/v1.0/me/messages/{messageId}/attachments   

body:

{       
  
"@odata.type": "#microsoft.graph.fileAttachment",      
  
 "name": "smime.p7m",      
  
 "contentType": "application/x-pkcs7-mime",      
  
 "contentBytes": "{contentBytes}"   
  
}  

Any feedback on what might be causing the issue would be appreciated.

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

2 answers

Sort by: Most helpful
  1. Rani Rishmawi 1 Reputation point
    2021-10-29T09:48:59.96+00:00

    Anything on this?

    Regards

    0 comments No comments

  2. Rani Rishmawi 1 Reputation point
    2021-11-01T10:05:03.827+00:00

    After some research on this, it looks like this is not an issue with ms graph. The thing is that we are using outlook for mobile on IOS to check the message after being manipulated and the outlook app does not update the attachment correctly which results in two attachments being displayed. If we query the message using ms graph explorer we can see that the attachment was replaced correctly. We concluded that this is a bug in Outlook app o IOS.

    To confirm, we reinstalled the outlook app on IOS and the message with its attachments was displayed correctly.

    Regards

    0 comments No comments