274 maintype, subtype = itm.text(1).split('/', 1) |
274 maintype, subtype = itm.text(1).split('/', 1) |
275 fname = itm.text(0) |
275 fname = itm.text(0) |
276 name = os.path.basename(fname) |
276 name = os.path.basename(fname) |
277 |
277 |
278 if maintype == 'text': |
278 if maintype == 'text': |
279 txt = open(fname, 'r', encoding="utf-8").read() |
279 with open(fname, 'r', encoding="utf-8") as f: |
|
280 txt = f.read() |
280 try: |
281 try: |
281 txt.encode("us-ascii") |
282 txt.encode("us-ascii") |
282 att = MIMEText(txt, _subtype=subtype) |
283 att = MIMEText(txt, _subtype=subtype) |
283 except UnicodeEncodeError: |
284 except UnicodeEncodeError: |
284 att = MIMEText( |
285 att = MIMEText( |