string payload expected: <type 'list'> error

Ramdas ramdaz at gmail.com
Fri Nov 27 04:43:31 EST 2009


On Nov 27, 2:39 am, Lie Ryan <lie.1... at gmail.com> wrote:
> Ramdas wrote:
> > Dear all,
>
> > I believe this is an error which was fixed in Python 2.3 itself. But I
> > am running Python 2,5.2 and error keeps on cropping up.
>
> > Here is my code to construct emails . It works perfectly when I dont
> > have any attachments. Please find my code at
>
> >http://dpaste.com/hold/125574/
>
> > However when I try constructing with attachments it crashes with this
> > error string payload expected: <type 'list'> error.
>
> Except if the traceback is due to a recursive function that doesn't
> terminate, please always post the FULL traceback. Don't summarize the
> error message.
>
> > Going through the trace error I discover that as I call the function
> > msg.as_string, the function . _handle_text(self, msg) expects a string
> > object but I am generating list object. Can someone advise what I need
> > to code to parse series of attachments into an email.
>
> > Help appreciated
>
> I smell this part of the code as particularly fishy:
>
> msg1 = MIMEBase(maintype, subtype)
> msg1.set_payload(MIMEText(fp.read()))
>
> why are you wrapping a MIMEText inside a MIMEBase?

I tried with MIMEBASE but it still fails...... I changed it to
MIMEText, hoping that might trick __handletext to think its a string
Anyway that also doesn't work.

Any ideas



More information about the Python-list mailing list