[Email-SIG] Creating message parts

Mark Sapiro mark at msapiro.net
Wed Sep 24 17:13:55 CEST 2008


Nicholas Cole wrote:
>
>I'm trying to create a message part that will later be attached to
>another message.  However, if I do
>
>E = email.mime.multipart.MIMEMultipart()
>print E.as_string()
>
>Then E is given a "MIME-Version: 1.0" header, which I don't think it
>should have (the "parent" email message will have that header, of
>course).
>
>I have a feeling, therefore, that I am doing something wrong!  Should
>I not be using the MIMEMultipart() calss for this purpose? And if not,
>what should I be using?


See <http://docs.python.org/lib/module-email.mime.text.html>.

You should use classes like email.mime.application.MIMEApplication,
email.mime.image.MIMEImage, email.mime.text.MIMEText, etc. to create
the various message parts and then append them to the payload of the
parent message.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Email-SIG mailing list