[Tutor] Python IMAP library
Cameron Simpson
cs at cskk.id.au
Sun Oct 17 19:25:33 EDT 2021
On 17Oct2021 17:40, Julius Hamilton <juliushamilton100 at gmail.com> wrote:
>Does anyone know what my options are for retrieving the email body of a
>specific email using this library?
>
>I’ll need a way to find the email. I guess I could search via subject
>header, if this library supports that.
Ths depends entirely on what you know. Email messages each have a unique
message-id (in the Message-ID header line). IMAP servers also allocate
messages persistent UIDs I believe.
But if all you've got is a subject line, then that's all you can search
for - bearing in mind that many of the messages in an email thread will
all have the same subject line.
>I believe I’ll use methods .fetch, .search and .select for this. I’ll
>be researching this, unless about anybody can provide some code for
>this.
You could look at the source code for hte getmail utility - it uses the
imaplib module directly to do its work:
http://pyropus.ca/software/getmail/
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list