2

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.

Fils
  • 47
  • 5
  • Refer the documentation, it talks about that contentlocation property and clearly tells [that do not use this property as it is not supported](https://learn.microsoft.com/en-us/graph/api/resources/fileattachment?view=graph-rest-1.0). – Dev Mar 20 '21 at 15:42
  • I missed this information. Nevertheless, the question is still valid - I don't know how to insert inline large images, AttachmentItem miss ContentId. I will modify the question. Thanks for the reply. – Fils Mar 25 '21 at 14:13
  • @Fils Did you ever figure this out? Am running into the same problem. – Caleb Sandfort Oct 24 '22 at 21:38
  • @CalebSandfort I 'solved' this problem by decreasing the resolution of inline images till the filesize was less than 3 MB. Not the best solution, but it's something. Let's hope Microsoft will fix this. – The_Fox Oct 25 '22 at 15:13

0 Answers0