0

I'm working with mailbox messages using Graph API. How to classify the messages as sent or received?

I found the similar query,Is there a way to differentiate an inbound (received) versus outbound (sent) email/message?

Thank you

Susi_003
  • 33
  • 5

2 Answers2

0

Can you try the below queries and see if this helps your scenario:

  1. To identify sent message - https://graph.microsoft.com/v1.0/me/messages?$filter=sender/emailAddress/address eq 'your mail address'

  2. To identify received message - https://graph.microsoft.com/v1.0/me/messages?$filter=sender/emailAddress/address ne 'your email address'

Dharman
  • 30,962
  • 25
  • 85
  • 135
Shweta
  • 351
  • 1
  • 4
  • Thanks for the answer. But when user sends mail to himself, the received inbox mail is identified as a sent mail. Also what if user sent a mail with delegation of other user (send as permission), sent mails in user mailbox is identified as received. Any idea to overcome this case? – Susi_003 Sep 02 '21 at 05:07
0

You can try the following steps and see if this helps your scenario:

  1. Get the mail folder collection directly under the root folder of the signed-in user. The returned collection includes any mail search folders directly under the root.

     GET /me/mailFolders
    
  2. Get messages in a specific folder in the user's mailbox - Use list messages endpoint for this.

     GET /me/mailFolders/{id}/messages
    
Dharman
  • 30,962
  • 25
  • 85
  • 135
Shweta
  • 351
  • 1
  • 4