eric6/UI/EmailDialog.py

changeset 8205
4a0f1f896341
parent 8143
2c730d5fd177
child 8218
7c09585bd960
--- a/eric6/UI/EmailDialog.py	Thu Apr 08 17:27:12 2021 +0200
+++ b/eric6/UI/EmailDialog.py	Thu Apr 08 18:27:47 2021 +0200
@@ -286,11 +286,14 @@
                         txt.encode("utf-8"), _subtype=subtype,
                         _charset="utf-8")
             elif maintype == 'image':
-                att = MIMEImage(open(fname, 'rb').read(), _subtype=subtype)
+                with open(fname, 'rb') as f:
+                    att = MIMEImage(f.read(), _subtype=subtype)
             elif maintype == 'audio':
-                att = MIMEAudio(open(fname, 'rb').read(), _subtype=subtype)
+                with open(fname, 'rb') as f:
+                    att = MIMEAudio(f.read(), _subtype=subtype)
             else:
-                att = MIMEApplication(open(fname, 'rb').read())
+                with open(fname, 'rb') as f:
+                    att = MIMEApplication(f.read())
             att.add_header('Content-Disposition', 'attachment', filename=name)
             msg.attach(att)
             

eric ide

mercurial