How to retrieve content of messages and attachment?

persistent_test 91 Reputation points
2022-05-30T08:47:34.077+00:00

I wanted to retrieve content of attachment and messages. For attachment, I am using this:
Objects.requireNonNull(new FileAttachmentStreamRequestBuilder(
Objects.requireNonNull(graphClient.users(userId).messages(
messageId)
.attachments(
Objects.requireNonNull(attachment.id))
.buildRequest().getRequestUrl())
.toString() + "/$value", graphClient, null).buildRequest().get());
but this is not retrieving me inputstream which it was earlier.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AtulThorat-MSFT 391 Reputation points
    2022-05-30T13:43:02.74+00:00

    Hi @11545032/persistenttest-7723,

    Hope you are doing well.

    As per message-get and attachment-get we can retrieve content of message and attachment as shown below.

    **For Messages**   
    GET /me/messages/{id}/$value   
    GET /users/{id | userPrincipalName}/messages/{id}/$value   
    GET /me/mailFolders/{id}/messages/{id}/$value   
    GET /users/{id | userPrincipalName}/mailFolders/{id}/messages/{id}/$value  
    
    **For Attachments**  
    GET /me/messages/{id}/attachments/{id}/$value  
    GET /users/{id | userPrincipalName}/messages/{id}/attachments/{id}/$value  
    

    206719-get-message-content.png

    206781-get-attachment-content.png

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.