當前位置: 首頁>>代碼示例>>Python>>正文


Python Message.extractEmails方法代碼示例

本文整理匯總了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
開發者ID:mturek,項目名稱:Test92,代碼行數:38,代碼來源:main.py


注:本文中的Message.extractEmails方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。