Help - email library not working as expected

Larry Bates lbates at swamisoft.com
Thu Jun 17 11:40:58 EDT 2004


I have found that the SmtpWriter class "hides" all the
complexity in creating emails like you want to send.

Check it out here:

http://motion.sourceforge.net/related/send_jpg.py

HTH,
Larry Bates
Syscon, Inc.

"Deathstar" <deathstar at altern.org> wrote in message
news:dd2d28c8.0406170418.a4389d5 at posting.google.com...
> Hi,
>
> I'm having some problems using the Python email library. I want to write a
mail
>
> that has a body, and an attachment with it. From what I understand, the
>
> set_payload() function would be specify the body, and attach() would
specify a
>
> MIME attachment Message.
>
> However this does not work. I get an error saying :
> 'str' object has no attribute 'append'
>
> I'm doing this with Python 2.3.2 on Windows XP SP1. What am I doing wrong
here?
>
> How do u specify the body and the attachment to the mail?
>
> ======== Code Snippet Start ========
> my_mail=Message()
> my_mail['From']=addr_frm
> my_mail['To']=addr_to
> my_mail['Subject']=sub
> my_mail.set_payload(bdy.read()) #Body of the mail
>
>
> attachment=MIMEMultipart(mimetypes.guess_type(att_name))
> att=open(att_name)
> attachment.set_payload(att.read()) #The attachment
>
> my_mail.attach(attachment)
>
> print my_mail.as_string()
> ======== Code Snippet End ========
>
> Regards,
> Deathstar





More information about the Python-list mailing list