How to add large (>3MB) inline attachment using Microsoft Graph API?

Viewed 220

I am trying to add a large inline attachment to the message, but I don't see a way to add ContentLocation information that is in FileAttachment. For small attachments I'm using FileAttachment, and it's work fine.

A simplified description of what I do:

Microsoft.Graph.FileAttachment fileAttachment = /*SOME FILEATTACHMENT*/


Microsoft.Graph.AttachmentItem attachmentItem = new()
{
    AttachmentType = Microsoft.Graph.AttachmentType.File,
    Name = fileAttachment.Name,
    Size = fileAttachment.ContentBytes.Length,
    ContentType = fileAttachment.ContentType
};

Microsoft.Graph.UploadSession uploadSession = await userRequestBuilder.Messages[ msgOnServer.Id ].Attachments.CreateUploadSession( attachmentItem ).Request().PostAsync();

using MemoryStream fileMemoryStream = new( fileAttachment.ContentBytes );

Microsoft.Graph.LargeFileUploadTask<Microsoft.Graph.AttachmentItem> fileUploadTask = new( uploadSession, fileMemoryStream );

Microsoft.Graph.UploadResult<Microsoft.Graph.AttachmentItem> uploadResult = await fileUploadTask.UploadAsync();

Everything works fine, but I don't know how to add ContentLocation information. Without this, I am not able to embed a larger image in the message.

Is there any way to add this information? Or maybe large inline attachments (images) need to be added differently?

EDIT: As @Dev noted, ContentLocation is not supported. But the problem with large images still exists. I need to specify at least ContentId, but it is not a part of AttachmentItem.

0 Answers
Related