Attachments are not available immediately after subscription notification
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
- Get Message and Attachment List
var msg = await graphClient.Me.Messages[MicrosoftId]
.Request()
.WithImmutableId()
.Expand(EXPAND_MIME_HEADERS) .Select("internetMessageId,internetMessageHeaders,createdDateTime,subject,bodyPreview,hasAttachments,uniqueBody,body,from,toRecipients,ccRecipients,bccRecipients,isDraft")
.GetAsync()
.ConfigureAwait(false);
var atts = await graphClient.Me.Messages[MicrosoftId].Attachments
.Request()
.WithImmutableId()
.Select("id,name,size,isInline,contentType,microsoft.graph.fileAttachment/contentId")
.GetAsync(cancelAttachments.Token)
.ConfigureAwait(false);
foreach(var att in atts){
//Fails with above error
//failure is intermittent
var attMS = await graphClient.Me
.Messages[msg.Id]
.Attachments[att.Id]
.Request()
.WithImmutableId()
.GetAsync()
.ConfigureAwait(false) as FileAttachment;
}
I expect attachments to download.......