Attachments are not available immediately after subscription notification

Joshua Grippo 0 Reputation points

After receiving a Subscription notification that an Email has been created. I check to see if the email has attachments. If it does, I attempt to download the attachments.
I will initially get the following exception:

Exception Type: Microsoft.Graph.ServiceException
Error: Code: ErrorItemNotFound
Message: The specified object was not found in the store., The store ID provided isn't an ID of an item.

If I repeatedly retry to download the attachments, it will eventually succeed after 4-5 minutes.

To Reproduce

  1. Get Message and Attachment List
    var msg = await graphClient.Me.Messages[MicrosoftId]
    .Expand(EXPAND_MIME_HEADERS) .Select("internetMessageId,internetMessageHeaders,createdDateTime,subject,bodyPreview,hasAttachments,uniqueBody,body,from,toRecipients,ccRecipients,bccRecipients,isDraft")

var atts = await graphClient.Me.Messages[MicrosoftId].Attachments

foreach(var att in atts){
//Fails with above error
//failure is intermittent
var attMS = await graphClient.Me
.ConfigureAwait(false) as FileAttachment;

I expect attachments to download.......

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