Open
Description
I am trying to attach an HTML file to an email.
I get the following error:
/usr/local/lib/python2.7/email/message.pyc in get(self, name, failobj)
358 is missing.
359 """
--> 360 name = name.lower()
361 for k, v in self._headers:
362 if k.lower() == name:
AttributeError: 'slice' object has no attribute 'lower'
Stepping into the code with ipython debugger it seems that it detects the MIME type of the file, correctly, as text/html
but this causes it to follow a different codepath which is where it fails: https://github.com/tomekwojcik/envelopes/blob/master/envelopes/envelope.py#L292
If I force it to use a generic mime type instead:
envelope.add_attachment("myfile.html", mimetype="application/octet-stream")
...then I can send the message but something weird happens - Gmail shows the message as having the file attached twice, even though if I go back and check the envelope
object it seems I have only one attachment:
In [18]: envelope._parts
Out[18]:
[('text/plain', 'my body text', 'utf-8'),
('application/octet-stream',
<email.mime.base.MIMEBase instance at 0x270cd40>)]
Metadata
Metadata
Assignees
Labels
No labels