Outlook 邮件 REST API:尽管在邮件中,但找不到文件夹

Outlook Mail REST API: folder not found despite being in a message

我尝试使用 REST API.

获取 Outlook 帐户的文件夹列表

使用 MailFolders 端点,我只得到文件夹的一个子集(例如,我没有得到 InboxSent Items文件夹)。

如果我列出该帐户的所有邮件,然后为每封邮件尝试获取 ParentFolderId,我会收到一堆 404 错误。我只能获得与从 MailFolders 端点获得的文件夹相同的文件夹。

当然,这适用于我拥有的所有其他 Office 365 帐户。而且这个帐户看起来与其他帐户没有什么不同。

这不是重命名文件夹的问题,因为我可以在 Outlook 中看到这些文件夹 UI。

当然,我在获取文件夹或列出消息时正确地对结果进行了分页。这同样适用于所有其他 Outlook 帐户。

我正在使用 https://outlook.office.com/api/v2.0/me/MailFolders?%24top=50 端点。

有什么见解吗?

谢谢,

杰里米

回应:

HTTP/1.1 404 Not Found 

Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true‌​;IEEE754Compatible=f‌​alse;charset=utf-8
Server: Microsoft-IIS/8.5
request-id: e98a3488-3441-474c-8cff-c905f8b9f299 
X-CalculatedFETarget: MWHPR1301CU001.internal.outlook.com
X-BackEndHttpStatus: 404
X-FEProxyInfo: MWHPR1301CA0012.NAMPRD13.PROD.OUTLOOK.COM
X-CalculatedBETarget: MWHPR16MB1661.namprd16.prod.outlook.com
X-BackEndHttpStatus: 404
OData-Version: 4.0
X-AspNet-Version: 4.0.30319
X-DiagInfo: MWHPR16MB1661
X-BEServer: MWHPR16MB1661
X-FEServer: MWHPR1301CA0012
X-Powered-By: ASP.NET
X-FEServer: BY2PR02CA0116
X-MSEdge-Ref: Ref A: 0872CED88164470BA7F119058A1F5CBF Ref B: BAYEDGE0318 Ref C: Thu Apr 27 10:58:51 2017 PST
Date: Thu, 27 Apr 2017 17:58:51 GMT

{
  "error":{
    "code":"ErrorItemNotFound",
    "message":"The specified object was not found in the store."
  }
}

我遇到了同样的问题。我通过首先获取文件夹的 count 来解决它,然后使用 $top 过滤器发出我的第二个请求以获取我的所有文件夹。请看以下代码:

$http.get("https://outlook.office.com/api/v2.0/me/MailFolders/$count")
         .then(function(response) {
            //RETRIEVE ALL FOLDERS
            $http.get("https://outlook.office.com/api/v2.0/me/MailFolders?$top="+response.data).then(...)

我们认为这是由于容器 class 属性 在丢失的文件夹上设置不正确造成的,这可能是在 IMAP 迁移(从 IMAP 邮件系统迁移到 Office 365)期间造成的。容器 class 设置为 IPF.Imap 而不是预期的 IPF.Note

要显示这些文件夹,您可以使用 MFCMapi 或 EWS 编辑器更改容器 class。这里有关于使用 MFCMapi 执行此操作的说明:

https://support.microsoft.com/en-us/help/3050475/you-can-t-view-mailbox-folders-on-an-exchange-activesync-or-outlook-client-after-an-imap-migration