How can I filter emails from a specific email address on Office 365 API?

老子叫甜甜 提交于 2019-12-11 08:09:57

问题


I've users with thousands of emails but I need to fetch only unread emails from specific people. I have the following call but it is not working for me.

curl -i https://graph.microsoft.com/v1.0/me/messages$filter=From/EmailAddress/Address eq 'alerts-noreply@mail.windowsazure.com' H 'Content-Type: application/x-www-form-urlencoded' -H 'Authorization: Bearer token ....'

{
  "error": {
    "code": "BadRequest",
    "message": "Unsupported segment type. ODataQuery: users/020f1da4-031d-4....26513bb0/messages=From/EmailAddress/Address",
    "innerError": {
      "request-id": "2aaaaeb...42-ffc6d0e44f3d",
      "date": "2017-01-24T01:30:44"
    }
  }
}

How can I fetch emails from MS Office API "FROM" specific people without fetching all emails to our system?


回答1:


You were missing the character ? after messages. To filter the messages from specify user with unread messages, you can use the request below:

GET:https://graph.microsoft.com/v1.0/me/messages?$filter=from/emailAddress/address+eq+'xx@xxxx.onmicrosoft.com'+and+isRead+eq+false



回答2:


You can find an example of how to do this, and other examples of using common query parameters in Microsoft Graph in Microsoft Graph optional query parameters.



来源:https://stackoverflow.com/questions/41818683/how-can-i-filter-emails-from-a-specific-email-address-on-office-365-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!