调用 /users/me/mailFolders
返回文件夹列表及其 id
、displayName
、parentFolderId
和一些计数器。
如何确定哪个文件夹是“收件箱”?
我不能使用 displayName
因为这可能是用户的母语。 Id
只是一个随机字符串。
我需要这个,因为我的应用会填充文件夹列表,并且我想将“选择”默认设置为收件箱(就像 Outlook 一样)。
最佳答案
对于默认文件夹,您可以使用“众所周知的名称”(在本例中为 inbox
)来获取正确的 id
。来自 the documentation :
Outlook creates certain folders for users by default. Instead of using the corresponding folder id value, for convenience, you can use the following well-known folder names when accessing these folders in a mailFolder collection:
ArchiveRoot
,ConversationHistory
,DeletedItems
,Drafts
,Inbox
,JunkEmail
,Outbox
, andSentItems
.
为了说明,在示例 Graph Explorer 中调用 /me/mailFolders/inbox
租户返回:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/mailFolders/$entity",
"id": "AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OAAuAAAAAAAiQ8W967B7TKBjgx9rVEURAQAiIsqMbYjsT5e-T7KzowPTAAAAAAEMAAA=",
"displayName": "Inbox",
"parentFolderId": "AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OAAuAAAAAAAiQ8W967B7TKBjgx9rVEURAQAiIsqMbYjsT5e-T7KzowPTAAAAAAEIAAA=",
"childFolderCount": 2,
"unreadItemCount": 59,
"totalItemCount": 60
}
关于microsoft-graph-api - 如何知道收件箱是哪个mailFolder?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48747065/