[Twisted-Python] IMAP BODYSTRUCTURE format & the email.Messages

Anders Hammarquist iko at cd.chalmers.se
Tue Jul 15 08:42:56 EDT 2003

In a message of Fri, 11 Jul 2003 18:14:07 +1200, "Tony Meyer" writes:
>Does anyone know of existing code to convert/format/flatten an email.Message
>into the correct format for IMAP's BODYSTRUCTURE request?  (it basically
>breaks down all the MIME parts of the message).  It can use twisted or
>imaplib, or neither, I don't care.

This is intended to be used from Twisted's imap server, but can probably
be adapted to other uses. It probably doesn't work out-of-the box (as I've
adapted it from a larger piece of code, and it's not a runnable example),
but it does produce something at least resembling what the RFC says it
should look like. Usage: You call getBody() from within IMailbox.fetch(),
setting ext to True if it is a BODYSTRUCTURE fetch. (self is a private
Message-type class, not the IMailbox, though it could probably be.)

Enjoy (and please let me know of any bugs in it).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-python
Size: 4191 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20030715/b11aa66d/attachment.py 
-------------- next part --------------
 -- Of course I'm crazy, but that doesn't mean I'm wrong.
Anders Hammarquist                                  | iko at cd.chalmers.se
Physics student, Chalmers University of Technology, | Hem: +46 31 88 48 50
G|teborg, Sweden.           RADIO: SM6XMM and N2JGL | Mob: +46 707 27 86 87

More information about the Twisted-Python mailing list