Microsoft Graph API - Messages

Bruno Lachot 6 Reputation points


By using Graph API to retrieve user messages, How identify emails sent and emails received by the user.

Sender or From properties can be different from user userPrincipalName if alias are used or if account created with a gmail address...

Moreever the filters on the user profile do not seem to work on personal accounts.$select=userPrincipalName,mail,otherMails

Thank you for your help.

Best Regards

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
13,000 questions
No comments
1 vote

5 answers

Sort by: Most helpful
  1. Saurabh Sharma 17,301 Reputation points Microsoft Employee

    @BrunoLachot-3318 I do no see any attributes in message object to identify if it is a sent or received one. I suggest you to reach out to Microsoft Graph Support to provide your feedback.

    Also, I am able to reproduce your other issue and $select is not working if I log in with Personal (Guest) account. I am checking internally on this issue and update you here on the same.

    No comments

  2. Bruno Lachot 6 Reputation points

    Thank you for your comments.

    Waiting for your additional information, I found another way via the beta API
    I can retrieve all mail addresses for account user. From there I can deduce if emails have been sent or received by the user.


    No comments

  3. Saurabh Sharma 17,301 Reputation points Microsoft Employee

    @BrunoLachot-3318 Thanks for sharing your solution as it will help other community members as well.
    Here are my findings - sender.emailAddress.Address is not userPrincipalName. Application needs to query the userObject [{id | userPrincipalName}] to find all the possible email aliases and match that with senderEmailAddress.
    Regarding $select, the support for $select is yet to be added for Microsoft Accounts.

    No comments

  4. Bruno Lachot 6 Reputation points

    I don't think that this request$select=userPrincipalName,mail,otherMails
    does not seem to work on a personal account

  5. Bruno Lachot 6 Reputation points

    Thanks for your answer.