eric6/UI/EmailDialog.py

changeset 8205
4a0f1f896341
parent 8143
2c730d5fd177
child 8218
7c09585bd960
equal deleted inserted replaced
8204:fd477cded1c1 8205:4a0f1f896341
284 except UnicodeEncodeError: 284 except UnicodeEncodeError:
285 att = MIMEText( 285 att = MIMEText(
286 txt.encode("utf-8"), _subtype=subtype, 286 txt.encode("utf-8"), _subtype=subtype,
287 _charset="utf-8") 287 _charset="utf-8")
288 elif maintype == 'image': 288 elif maintype == 'image':
289 att = MIMEImage(open(fname, 'rb').read(), _subtype=subtype) 289 with open(fname, 'rb') as f:
290 att = MIMEImage(f.read(), _subtype=subtype)
290 elif maintype == 'audio': 291 elif maintype == 'audio':
291 att = MIMEAudio(open(fname, 'rb').read(), _subtype=subtype) 292 with open(fname, 'rb') as f:
293 att = MIMEAudio(f.read(), _subtype=subtype)
292 else: 294 else:
293 att = MIMEApplication(open(fname, 'rb').read()) 295 with open(fname, 'rb') as f:
296 att = MIMEApplication(f.read())
294 att.add_header('Content-Disposition', 'attachment', filename=name) 297 att.add_header('Content-Disposition', 'attachment', filename=name)
295 msg.attach(att) 298 msg.attach(att)
296 299
297 return msg 300 return msg
298 301

eric ide

mercurial