[Tutor] IMAP library

Michael Janssen Janssen@rz.uni-frankfurt.de
Wed Apr 30 14:10:05 2003


On Wed, 30 Apr 2003 guillermo.fernandez@epfl.ch wrote:

> Hi!
>
> I'm trying to understand how the IMAP library works. For that I've copied this program and modified it a little bit:
>
> import getpass, imaplib, string
>
> M = imaplib.IMAP4('mailbox.site.com')
> M.login(getpass.getuser(), getpass.getpass())
> M.select('INBOX',1)
> typ, data = M.search(None, "FROM \"a.friend@site.com\"")

the docs say, you have two possibilities how to write the search
criterium:
"""
msgnums = M.search(None, 'FROM', '"LDJ"')

# or:
msgnums = M.search(None, '(FROM "LDJ")')
"""

it seems, that the type of quote (single/ dubble) matters:

>>> M.search(None, "(FROM 'Janssen@rz.uni-frankfurt.de')")
('OK', [''])
>>> M.search(None, '(FROM "Janssen@rz.uni-frankfurt.de")')
('OK', ['1 2 3 4 14 18 21 25 26 40 42'])

[i post a lot of messages to myself ;-)]


does anyone know how to search for X-Header Values (Like "X-BeenThere:
tutor@python.org")?

Michael