Problems with multipart messages w/email class

Joseph Wilhelm jwilhelm at outsourcefinancial.com
Fri Mar 1 13:12:42 EST 2002


I'm trying to send an email via the email class in Python 2.2 with an
attached PDF. Easy feat, I assume. However, email.Generator is having
problems in _handle_multipart() (Caused by some strange __getitem__
error in Message)

>>> outer.get_payload()
<email.MIMEBase.MIMEBase instance at 0x8151904>
>>> 

That works fine. However...

>>> for part in outer.get_payload():
...     print "Blah"
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/opt/python/lib/python2.2/email/Message.py", line 151, in
__getitem__
    return self.get(name)
  File "/opt/python/lib/python2.2/email/Message.py", line 214, in get
    name = name.lower()
AttributeError: 'int' object has no attribute 'lower'
>>>

I originally found this error because of this traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/opt/python/lib/python2.2/email/Message.py", line 59, in
as_string
    g(self, unixfrom=unixfrom)
  File "/opt/python/lib/python2.2/email/Generator.py", line 83, in
__call__
    self._write(msg)
  File "/opt/python/lib/python2.2/email/Generator.py", line 104, in
_write
    self._dispatch(msg)
  File "/opt/python/lib/python2.2/email/Generator.py", line 134, in
_dispatch
    meth(msg)
  File "/opt/python/lib/python2.2/email/Generator.py", line 240, in
_handle_multipart
    for part in msg.get_payload():
  File "/opt/python/lib/python2.2/email/Message.py", line 151, in
__getitem__
    return self.get(name)
  File "/opt/python/lib/python2.2/email/Message.py", line 214, in get
    name = name.lower()
AttributeError: 'int' object has no attribute 'lower'

I got this from calling message.as_string()

I can provide my code used to generate the email if necessarry, however
I don't believe it should be. I derived my code directly from an example
in the email documentation.  Any help would be appreciated.

--Joseph Wilhelm






More information about the Python-list mailing list