关于Python Gmail-api的API一般理解

时间:2015-06-12 17:35:03

标签: python gmail email-attachments gmail-api

我刚刚开始编程一年前(打开和关闭),我正在尝试从我的个人GMAIL帐户离线保存对文件夹的附件。

我被建议使用:

https://developers.google.com/gmail/api/quickstart/python 我设置了

我对我的帐户进行了身份验证,现在我正在尝试使用此工具。

我有一些初步问题

什么是用户名?         这是我的电子邮件(tttt@xxxx.xxxx)
           或其他人的电子邮件(ppppp@yyyy.yyy)

如何获取电子邮件ID?

这些问题源于......

 GET https://www.googleapis.com/gmail/v1/users/userId/messages/messageId/attachments/id

来自页面:

https://developers.google.com/gmail/api/v1/reference/users/messages/attachments/get

我再次向初学者学习......

谢谢

1 个答案:

答案 0 :(得分:1)

只需使用“我”作为docI中的userId。

要首先获取messageId,您必须使用以下内容搜索(列出)消息:

  

resp = gmail.users()。messages()。list(userId =“me”,q =“has:attachment subject:'foo bar'before:”2014-01-05“)。execute()< / p>

然后你可以遍历那个resp和

中的'messages'
  

gmail.users()。messages()。get(userId =“me”,id = message ['id'])。execute()

Gmail API指南非常有用,请查看它们,例如: https://developers.google.com/gmail/api/guides/filtering