email and unicode

janwillem jwevandijk at xs4all.nl
Sun Apr 18 06:02:23 EDT 2010


I have a script that extracts attachments from all emails in a mbox
(largely based on  http://code.activestate.com/recipes/302086-strip-attachments-from-an-email-message/;
thanks ActiveState). It works fine until it encounters an attachment
with a unicode file name (Ukrainian in my case). I cannot get working
the line
msg.set_payload(replace)
which is line 39 in the activestate snippet.

How can you get the unicode file name into the replace string of line
35 of the snippet:
replace = ReplaceString % dict(content_type=ct,
                                       filename=fn,
                                       params=params)
without getting this nasty error message about ascii encoding?



More information about the Python-list mailing list