本文整理汇总了Python中gmail.Gmail.get_message_ids方法的典型用法代码示例。如果您正苦于以下问题:Python Gmail.get_message_ids方法的具体用法?Python Gmail.get_message_ids怎么用?Python Gmail.get_message_ids使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gmail.Gmail
的用法示例。
在下文中一共展示了Gmail.get_message_ids方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gmail import Gmail [as 别名]
# 或者: from gmail.Gmail import get_message_ids [as 别名]
def __init__(self, username, password):
g = Gmail(username, password)
graph_out = csv.writer(open('email_graph.csv', 'wb'))
viewed_messages = []
for folder in g.list_folders(): # iterate through all folders in the account
# print "%s: %s" % (folder, g.get_message_ids(folder)) # NOTE: uncomment this to see which ids are in each folder
for message_id in g.get_message_ids(folder): # iterate through message IDs
if message_id not in viewed_messages: # ...but don't repeat messages
# print "Processing %s" % message_id
msg = g.get_message(message_id)
for line in msg.split('\n'): # grab the from and to lines
line = line.strip()
if line[0:5] == "From:":
msg_from = line[5:].strip()
elif line[0:3] == "To:":
msg_to = line[3:].strip()
try:
# print "%s, %s" % (msg_from, msg_to) # DEBUG
graph_out.writerow([msg_from, msg_to]) # output the from and to
except UnboundLocalError: # ignore if we can't read the headers
pass
示例2: __init__
# 需要导入模块: from gmail import Gmail [as 别名]
# 或者: from gmail.Gmail import get_message_ids [as 别名]
def __init__(self, username, password):
e = Gmail(username, password)
# e.select_folder("waiting")
message_ids = e.get_message_ids()
self.get_date(e, message_ids)
示例3: Copyright
# 需要导入模块: from gmail import Gmail [as 别名]
# 或者: from gmail.Gmail import get_message_ids [as 别名]
# encoding: utf-8
"""
email_stats.py
Created by Hilary Mason on 2011-01-31.
Copyright (c) 2011 Hilary Mason. All rights reserved.
"""
import sys, os
from gmail import Gmail
if __name__ == '__main__':
g = Gmail("[email protected]", "stratar0x")
folder_stats = {}
folder_stats['inbox'] = len(g.get_message_ids())
for folder_name in g.list_folders():
folder_stats[folder_name] = len(g.get_message_ids(folder_name))
for folder_name, count in folder_stats.items():
print "Folder %s, # messages: %s" % (folder_name, count)
########NEW FILE########
__FILENAME__ = email_timestamps
#!/usr/bin/env python
# encoding: utf-8
"""
email_timestamps.py