Can I add attachment with the event? Could you please provide me method to add attachment to event and also how to set attachment file path for the same?
Can I add attachment with the event? Could you please provide me method to add attachment to event and also how to set attachment file path for the same?
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
FileAttachment attachment = new FileAttachment();
attachment.name = "menu.txt";
attachment.contentBytes = Base64.getDecoder().decode("base64bWFjIGFuZCBjaGVlc2UgdG9kYXk=");
graphClient.me().events("AAMkAGI1AAAt9AHjAAA=").attachments()
.buildRequest()
.post(attachment);
(How to set the path of the attached File)
Hi @vandanaRatnaparkhi-8204 , Thanks for reaching out please refer the below example for
Attachment can be added to a message.attachments
Example:
FileAttachment fileAttachment = new FileAttachment();
fileAttachment.name = "Example text file";
Path path = Paths.get("/Users/user/Desktop/Text.txt");
fileAttachment.contentBytes = Files.readAllBytes(path);
LinkedList<Attachment> attachmentsList = new LinkedList<Attachment>();
attachmentsList.add(fileAttachment);
AttachmentCollectionResponse attachmentCollectionResponse = new AttachmentCollectionResponse();
attachmentCollectionResponse.value = attachmentsList;
AttachmentCollectionPage attachmentCollectionPage = new AttachmentCollectionPage(attachmentCollectionResponse, null);
// add to your message
message.attachments = attachmentCollectionPage;
Please also refer this DOC
4 people are following this question.