【问题标题】:How to delete a mail sent to someone in particular and that is inside the Sent mailbox?如何删除特定发送给某人的邮件,并且该邮件位于已发送邮箱中?
【发布时间】:2019-08-09 18:14:43
【问题描述】:

我将 Gmail API 与 Python 一起使用。考虑到邮件在已发送邮箱中,我想删除特别发送给某人的邮件。

我发现以下内容,但我认为它会删除收件箱内的邮件,而不是已发送邮箱内的邮件:https://developers.google.com/gmail/api/v1/reference/users/messages/delete

【问题讨论】:

    标签: python-3.x gmail-api


    【解决方案1】:

    您可以删除收件箱和已发送收件箱中的任何邮件。您只需要消息的 ID。

    您可以获得后者,例如通过带有可选查询参数的listing,例如分配给查询参数q"to:someuser@example.com"

    或者,如果您知道线程 ID - get 属于该线程的消息并选择要删除的消息。

    【讨论】:

    • 谢谢。我正在尝试使用service.users().messages().delete(userId='me', id=message_to_delete['id']).execute(),但是,我收到一个错误提示Insufficient Permission。这是我定义的范围:SCOPES = 'https://mail.google.com/'。你能帮帮我吗?
    • 您的作用域是正确的,但如果您曾经更改过作用域,则应在此之后删除 token.pickle 文件,然后再运行代码。范围问题与我之前给你的答案的质量无关。
    猜你喜欢
    • 1970-01-01
    • 2012-03-17
    • 2013-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多