Send mail with multiple attachment using Graph API

I'm using Microsoft-Graph API version 1.4 and trying to send mail with attachment using following code..

IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();

Message message = new Message();
message.subject = "Meet for lunch?";
ItemBody body = new ItemBody();
body.contentType = BodyType.TEXT;
body.content = "The new cafeteria is open.";
message.body = body;
LinkedList<Recipient> toRecipientsList = new LinkedList<Recipient>();
Recipient toRecipients = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.address = "";
toRecipients.emailAddress = emailAddress;
message.toRecipients = toRecipientsList;
LinkedList<Attachment> attachmentsList = new LinkedList<Attachment>();
FileAttachment attachments = new FileAttachment(); = "attachment.txt";
attachments.contentType = "text/plain";
attachments.contentBytes = "SGVsbG8gV29ybGQh";
message.attachments = attachmentsList;

Ref.Link: Graph-Send-Mail

But, message.attachments requires AttachmentCollectionPage object not LinkedList();

Can anyone help me to send a mail with multiple attachment.


Read more here:

Content Attribution

This content was originally published by Vivek Buddhadev at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: