printing email parts of type message/external-body??

Magnus Therning magnus.therning at wanadoo.nl
Sun Apr 20 12:18:01 EDT 2003


Hi,

I am having problems with the following piece of code, would appreciate
any insight that can be offered!

There should be some headers that describes the external body (mime type
and so on), but I haven't found a way to add those.


---- test.py ------------
from email.Message import Message

meb_message = Message()
meb_message.add_header('Content-Type', 'message/external-body',
    access_type='local-file')
meb_message.set_payload('name="test"\n')
print meb_message
-------------------------
magnus at die:[test].$ python test.py

Traceback (most recent call last):
 File "test.py", line 8, in ?
   print meb_message
 File "/usr/lib/python2.2/email/Message.py", line 97, in __str__
   return self.as_string(unixfrom=True)
 File "/usr/lib/python2.2/email/Message.py", line 107, in as_string
   g.flatten(self, unixfrom=unixfrom)
 File "/usr/lib/python2.2/email/Generator.py", line 100, in flatten
   self._write(msg)
 File "/usr/lib/python2.2/email/Generator.py", line 128, in _write
   self._dispatch(msg)
 File "/usr/lib/python2.2/email/Generator.py", line 154, in _dispatch
   meth(msg)
 File "/usr/lib/python2.2/email/Generator.py", line 302, in _handle_message
   g.flatten(msg.get_payload(0), unixfrom=False)
 File "/usr/lib/python2.2/email/Message.py", line 179, in get_payload
   raise TypeError, i
TypeError: 0
-------------------------

/M

-- 
Magnus Therning                    (OpenPGP: 0x6A83A7DF)

No matter what they do, companies are sure to annoy someone.
     -- Deborah Branscum




More information about the Python-list mailing list