libgmail: attaching files

wal rainwolf at gmail.com
Wed Oct 4 12:48:28 EDT 2006


 How does one attach files to emails using libgmail?  The following code
http://pramode.net/articles/lfy/fuse/4.txt
works fine when said files are simple text files, but it failes as soon as 
the files are wild binary files, even attaching the source of an email in a 
text file (.eml files) failes.
What am I missing here? Any hints?
 The output I get when attemting to send binary files using the code above 
is pasted below.

have fun,
wal

----------------------------------
Traceback (most recent call last):
  File "C:\Documents and 
Settings\lucp1735\Desktop\libgmail-0.1.5.1\knujon.py", line 24, in <module>
    if ga.sendMessage(fs):
  File "C:\Documents and 
Settings\lucp1735\Desktop\libgmail-0.1.5.1\libgmail.py", line 582, in 
sendMessage
    msgStr = mimeMessage.as_string()
  File "C:\program files\Python25\lib\email\message.py", line 131, in 
as_string
    g.flatten(self, unixfrom=unixfrom)
  File "C:\program files\Python25\lib\email\generator.py", line 84, in 
flatten
    self._write(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 109, in 
_write
    self._dispatch(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 135, in 
_dispatch
    meth(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 201, in 
_handle_multipart
    g.flatten(part, unixfrom=False)
  File "C:\program files\Python25\lib\email\generator.py", line 84, in 
flatten
    self._write(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 109, in 
_write
    self._dispatch(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 135, in 
_dispatch
    meth(msg)
  File "C:\program files\Python25\lib\email\generator.py", line 266, in 
_handle_message
    g.flatten(msg.get_payload(0), unixfrom=False)
  File "C:\program files\Python25\lib\email\message.py", line 185, in 
get_payload
    raise TypeError('Expected list, got %s' % type(self._payload))
TypeError: Expected list, got <type 'str'> 





More information about the Python-list mailing list