本文整理匯總了Python中Message.extractEmails方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.extractEmails方法的具體用法?Python Message.extractEmails怎麽用?Python Message.extractEmails使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Message
的用法示例。
在下文中一共展示了Message.extractEmails方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: findRoot
# 需要導入模塊: import Message [as 別名]
# 或者: from Message import extractEmails [as 別名]
def findRoot(serviceGmail, serviceUser): # Edited by FH: uses the user
root = []
user = "me" # Use the user who authorized the call
userData = serviceUser.people().get(userId='me').execute()
query = 'in:sent'
try:
userEmail = userData['emails'][0]['value']
root.append(userEmail)
query = 'in:sent' + ' -' + userEmail
except:
pass
# max maxResults = 10
# response = Message.ListMessagesMatchingQuery(service, user, query)
response = serviceGmail.users().messages().list(userId=user, q=query, maxResults=1).execute()
numberOfMessages = response['resultSizeEstimate']
while numberOfMessages:
messageID = response['messages'][0]['id']
# extract the vFrom
msg = Message.GetMessage(serviceGmail, user, messageID)
for i in range(len(msg['payload']['headers'])):
name = msg['payload']['headers'][i]['name']
value = msg['payload']['headers'][i]['value']
if name == 'From':
vFrom = Message.extractEmails(value)
if vFrom[0] not in root:
root.append(vFrom[0])
print root
query = query + ' -' + vFrom[0]
response = serviceGmail.users().messages().list(userId=user, q=query).execute()
numberOfMessages = response['resultSizeEstimate']
return root