this is not enough.

when a part is mulitpart/alternative, i must find out which sub part i
need, not all the subparts. so i must know when the alternative is
ended.


John Machin 写道:

> 叮叮当当 wrote:
> > hi, all
> >
> > when a email body consist with multipart/alternative,  i must know when
> > the boundary ends to parse it,
> >
> > but the email lib have not provide some function to indicate the
> > boundary end, how to solve it ?
>
> By reading the manual.
> http://docs.python.org/lib/module-email.Message.html
>
> You don't need to concern yourself with boundaries -- a high-level
> parser is provided.
>
> Here's a simple example:
>
> This script:
>
> msg_text = """
> [snip -- message is some plain text plus an attached file]
> """
> import email
> pmsg = email.message_from_string(msg_text)
> for part in pmsg.walk():
>     print part.get_content_type(), part.get_filename("<<NoFileName>>")
>
> produced this output:
>
> multipart/mixed <<NoFileName>>
> text/plain <<NoFileName>>
> application/octet-stream Extract.py
>
> For a more comprehensive example, see
> http://docs.python.org/lib/node597.html
> 
> HTH,
> John

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to