如何在执行标签Resource.ListRequest时获取标签线程未读?
我在排除Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest时试图获取ThreadsUnread属性,但它带有空值。
这是我的代码:
Google.Apis.Gmail.v1.UsersResource.LabelsResource.ListRequest labelReq = service.Users.Labels.List("me");
IList<Google.Apis.Gmail.v1.Data.Label> labels = labelReq.Execute().Labels;
在请求中我需要问什么ThreadsUnread
或MessagesUnread
值?
请求中有一个名为“fields”的属性。它可以用字符串设置。但我在哪里可以找到该字符串的选项?
使用Users.labels.get。在try-it部分执行此操作:
GET https://www.googleapis.com/gmail/v1/users/userId/labels/id
userId:我
id:INBOX
并执行,响应会像下面这样:
{
"id": "INBOX",
"name": "INBOX",
"messageListVisibility": "hide",
"labelListVisibility": "labelShow",
"type": "system",
"messagesTotal": 1808,
"messagesUnread": 1610,
"threadsTotal": 454,
"threadsUnread": 323
}
还有你正在寻找的"threadsUnread": 323
。
在撰写本文时(2019年3月),您在列表时无法获得计数。您必须随后请求每个标签的详细信息以获取详细信息。非常缓慢,昂贵且坦率地说是不必要的。等效的Microsoft Graph API没有此限制。
• 如何使用 Python 和 Gmail API 阅读电子邮件
• 如何使用App脚本发送交互式Gmail并接收他们的回复?
• 如何将 google_gmail1::Gmail<HttpsConnector<HttpConnector>> 传递给线程生成?
• 无法更改 Gmail 中的 IMAP 和 SMTP 设置
• 使用 codeigniter 通过 gmail 发送邮件时,邮件不会进入收件人邮件的收件箱
• 为 gmail api 添加了测试用户,但无法测试功能,测试用户返回 403
• 我想用服务帐号处理 Google Work Space Group 邮件,但身份验证不起作用
• 是否有针对 Google API 错误 400 的任何解决方案?
• Error implementing Rails mail_form gem “NameError in ContactsController#new”