Get the Gmail attachment filename without downloading it

后端 未结 4 1966
有刺的猬
有刺的猬 2020-12-31 09:56

I\'m trying to get all the messages from a Gmail account that may contain some large attachments (about 30MB). I just need the names, not the whole files. I found a piece of

4条回答
  •  失恋的感觉
    2020-12-31 10:33

    Rather than fetch RFC822, which is the full content, you could specify BODYSTRUCTURE.

    The resulting data structure from imaplib is pretty confusing, but you should be able to find the filename, content-type and sizes of each part of the message without downloading the entire thing.

提交回复
热议问题