gmali-api如何获取已读和未读或发送和接收的邮件数?
How to get the number of mail read and unread or sent and received with gmali-api?
我想使用 python 来了解已发送和已接收的电子邮件数量。
label_id_one = 'INBOX'
label_id_two = 'UNREAD'
# Getting all the unread messages from Inbox
unread_msgs = GMAIL.users().messages().list(userId='me', labelIds=[label_id_one, label_id_two]).execute()
当我使用此代码时,我可以从收件箱中获取未读邮件的数量。
但是如何获取已读邮件的数量?
使用所有邮件数减去未读邮件数?我觉得这样不好。
我在这个link查询了API,但是没有API提供这样的数据。
我怎样才能得到这样的数据?
我认为您要查找的信息不存在。最接近的是 Users: getProfile
在响应中有一个字段
messagesTotal integer The total number of messages in the mailbox.
{
"emailAddress": "me@gmail.com",
"messagesTotal": 66617,
"threadsTotal": 14010,
"historyId": "4618566"
}
但是,一旦您删除一条消息,数据就会发生变化,您的总按摩次数将减少一次。
就发送的消息而言,您可以执行 message.list 并在已发送文件夹中搜索消息并取回结果,但这将是自您上次清除后发送的消息文件夹。
回答:gmail api 中没有数据表明您在 gmail 帐户的生命周期内发送或接收了多少封电子邮件。你能得到的最接近的东西是
- 已发送:已发送文件夹中的邮件数 (in:sent)
- 已收到:您帐户中不在已发送文件夹中的邮件数。 (不是 in:sent)
一旦您删除一条消息,它就会改变。
勾选未读not in:sent label:unread
未读消息
unread_msgs = GMAIL.users().messages().list(userId='me', q='not in:sent label:unread').execute()
阅读消息
unread_msgs = GMAIL.users().messages().list(userId='me', q='not in:sent label:read').execute()
我想使用 python 来了解已发送和已接收的电子邮件数量。
label_id_one = 'INBOX'
label_id_two = 'UNREAD'
# Getting all the unread messages from Inbox
unread_msgs = GMAIL.users().messages().list(userId='me', labelIds=[label_id_one, label_id_two]).execute()
当我使用此代码时,我可以从收件箱中获取未读邮件的数量。
但是如何获取已读邮件的数量?
使用所有邮件数减去未读邮件数?我觉得这样不好。
我在这个link查询了API,但是没有API提供这样的数据。
我怎样才能得到这样的数据?
我认为您要查找的信息不存在。最接近的是 Users: getProfile
在响应中有一个字段
messagesTotal integer The total number of messages in the mailbox.
{
"emailAddress": "me@gmail.com",
"messagesTotal": 66617,
"threadsTotal": 14010,
"historyId": "4618566"
}
但是,一旦您删除一条消息,数据就会发生变化,您的总按摩次数将减少一次。
就发送的消息而言,您可以执行 message.list 并在已发送文件夹中搜索消息并取回结果,但这将是自您上次清除后发送的消息文件夹。
回答:gmail api 中没有数据表明您在 gmail 帐户的生命周期内发送或接收了多少封电子邮件。你能得到的最接近的东西是
- 已发送:已发送文件夹中的邮件数 (in:sent)
- 已收到:您帐户中不在已发送文件夹中的邮件数。 (不是 in:sent)
一旦您删除一条消息,它就会改变。
勾选未读not in:sent label:unread
未读消息
unread_msgs = GMAIL.users().messages().list(userId='me', q='not in:sent label:unread').execute()
阅读消息
unread_msgs = GMAIL.users().messages().list(userId='me', q='not in:sent label:read').execute()