【问题标题】:Need to change gsuite users signature in gmail需要更改 gmail 中的 gsuite 用户签名
【发布时间】:2019-05-14 10:45:18
【问题描述】:

我已经研究了两个星期,但找不到任何信息如何通过 python 脚本更改用户在 gmail 中的签名。你有解决这个问题的办法吗?

【问题讨论】:

  • 欢迎加入堆栈,请阅读stackoverflow.com/help/how-to-answer。在提出问题时,最好发布您当前使用的代码以及您在使用该代码时遇到的任何问题。如果您已经完成了一些研究,那么您所做的研究的链接也会有所帮助。 我找不到任何信息这句话是非常不可能的,因为 Google 中有数十亿个页面,你一定找到了一些没有帮助的东西

标签: python gmail-api


【解决方案1】:

Gmail 设置 API 具有允许管理用户签名的方法,您可以在此处找到有关他们的信息 Manage signature

您应该知道,此 API 已弃用已被弃用,并将于 2019 年 10 月 16 日被拒绝。请尽快迁移到 Gmail API,以避免对您的应用程序造成干扰。

Gmail API

Manag signature settings 声明您应该使用 要在 Gmail API 中管理电子邮件签名,请使用 SendAs 资源。这将让您设置签名。

Python

我建议您关注python quick start 并尝试编辑它以与 sendAs 方法一起使用

from __future__ import print_function
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools

# If modifying these scopes, delete the file token.json.
SCOPES = 'https://www.googleapis.com/auth/gmail.readonly'

def main():
    """Shows basic usage of the Gmail API.
    Lists the user's Gmail labels.
    """
    # The file token.json stores the user's access and refresh tokens, and is
    # created automatically when the authorization flow completes for the first
    # time.
    store = file.Storage('token.json')
    creds = store.get()
    if not creds or creds.invalid:
        flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
        creds = tools.run_flow(flow, store)
    service = build('gmail', 'v1', http=creds.authorize(Http()))

    # Call the Gmail API
    results = service.users().labels().list(userId='me').execute()
    labels = results.get('labels', [])

    if not labels:
        print('No labels found.')
    else:
        print('Labels:')
        for label in labels:
            print(label['name'])

if __name__ == '__main__':
    main()

【讨论】:

    猜你喜欢
    • 2023-02-04
    • 2018-07-03
    • 2017-05-03
    • 1970-01-01
    • 2020-07-16
    • 2017-08-21
    • 2021-11-02
    • 1970-01-01
    • 2021-09-21
    相关资源
    最近更新 更多