I want to use python to know how many emails have been sent and how many have been received.
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()
When I use this code,I can get the count of unread mails from inbox.
But how to get the count of readed mails?
Use the count of all mails minus unread mails?I don't think that's good.
I queried the API at this link, but no API provided such data.
How can I get such data?
I dont think the information you are looking for exists. The closest thing would be Users: getProfile
which has a field in the response
However as soon as you delete a message the data is going to change and you will have one less total massages.
As far as messages sent you could do a message.list and search for the messages in the sent folder and get the result back for that but thats going to be the messages you sent since you last cleaned out that folder.
Answer: There is no data in the gmail api that states how many emails you have sent or received in the lifetime of your gmail account. The closest thing you could get would be
which would change as soon as you deleted a message.
Tip: search messages
Check Not read
not in:sent label:unread
unread messages
read messages