134 Part II — Getting Inside Gmail
getQuotaInfo
The getQuotaInfomethod allows you to retrieve information on how much
storage you are taking up inside Gmail. It returns an array of megabytes used,
total megabytes available, and percentage of storage used.
getUnreadMsgCount
When invoked, the getUnreadMsgCountmethod returns an integer equal to the
number of unread messages within the Inbox:
new_messages = ga.getUnreadMsgCount()
Reading the First Message in the Inbox
Putting together the methods discussed so far, you can display the messages in the
Inbox, and information about the amount of storage you have left, with the code
in Listing 7-3.
Listing 7-3:Using Python to Display the First Message in the Inbox
#!/usr/bin/python2.3
import Libgmail
ga = Libgmail.GmailAccount(“[email protected]”,
“mymailismypass”)
ga.login()
folder = ga.getMessagesByFolder(‘inbox’)
for thread in folder:
print thread.id, len(thread), thread.subject
for msg in thread:
print “Message ID:”, msg.id
print “Message Number:”, msg.number
print “Message Subject:”, msg.subject
print msg.source
Keeping Your Powder Dry
The remaining methods —sendMessage, trashMessage, trashThread, getLabelNames,
createLabel, deleteLabel, renameLabel, and storeFile— are, apart from being self-
explanatorily named, covered in great detail in the remainder of this book.