[英]How to get office 365 outlook's folders name from a mailbox
I have authenticated for office 365 outlook using passport js 我已经使用护照js对Office 365 Outlook进行了身份验证
Now I have access token 现在我有访问令牌
So I am looking for to get all folders name with their respective folder Id. 因此,我正在寻找所有具有相应文件夹ID的文件夹名称。
I am using node-outlook library but I am not aware what APIs they have provided get only folders path and folder id. 我正在使用节点外观库,但是我不知道它们提供的API仅获得文件夹路径和文件夹ID。
Thanks 谢谢
If you only want to get the folder name and folder Id, you can use the following api call: 如果只想获取文件夹名称和文件夹ID,则可以使用以下api调用:
$http.get("https://outlook.office.com/api/v2.0/me/MailFolders/$select=Id,ChildFolderCount,DisplayName")
Since the above api, only returns main folders, I strongly suggest that you also select ChildFolderCount and add a check in the response, if ChildFolderCount>0, then get the subfolders of the parent by the following call: 由于上述api仅返回主文件夹,因此我强烈建议您还选择ChildFolderCount并在响应中添加一个检查,如果ChildFolderCount> 0,则通过以下调用获取父级的子文件夹:
$http.get("https://outlook.office.com/api/v2.0/me/MailFolders/"+parent.Id+"/childfolders?$top="+parent.ChildFolderCount)
where parent is the folder with ChildFolderCount>0. 其中parent是ChildFolderCount> 0的文件夹。
The folder resource has a DisplayName
property, so that should get what you want. 文件夹资源具有
DisplayName
属性,因此应该可以得到所需的内容。 ( Reference ). ( 参考 )。
You can also explore the API over at https://oauthplay.azurewebsites.net/ . 您也可以通过https://oauthplay.azurewebsites.net/浏览API。 For example, I did a GET on
https://outlook.office.com/api/v2.0/me/mailfolders
, and this is an example of the result: 例如,我在
https://outlook.office.com/api/v2.0/me/mailfolders
上进行了GET操作,这是结果的示例:
{
"Id": "AQMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMgBjYTliODJhNTIALgAAA6Ii1CwFSf1Ai6F6MypimPkBAGTbcv4AqpNHlH0kubDE5QwAAAIBDwAAAA==",
"DisplayName": "Drafts",
"ParentFolderId": "AQMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMgBjYTliODJhNTIALgAAA6Ii1CwFSf1Ai6F6MypimPkBAGTbcv4AqpNHlH0kubDE5QwAAAIBCAAAAA==",
"ChildFolderCount": 0,
"UnreadItemCount": 2,
"TotalItemCount": 9
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.