--- 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)