From 0ab5622bd04301db5e4512c1c2ffb51e2ad7f501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 1 Jun 2022 18:02:19 +0200 Subject: Add attachements-only to mail urls. --- do.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/do.py b/do.py index eb63ea7..ea9bff2 100755 --- a/do.py +++ b/do.py @@ -132,22 +132,23 @@ def resolve_mail(mode, source_file_name, addr, frag, comment): with open(mailfile, 'rb') as f: msg = email.message_from_binary_file(f, policy=default) - if mode == 'tex': - outstr += '\\begin{verbatim}\n' + if not frag == 'attachments-only': + if mode == 'tex': + outstr += '\\begin{verbatim}\n' - # mail += msg.get_content_type() + '\n' + # mail += msg.get_content_type() + '\n' - body = msg.get_body(preferencelist=('plain', 'html')) - for field in ['Date', 'From', 'To' 'Cc', 'Subject']: - h = msg.get(field) - if h: outstr += f'{field}: {h}\n' - outstr += '\n' - if frag == 'short': - outstr += shorten_mail(body.get_content()) - else: - outstr += body.get_content() - if mode == 'tex': - outstr += '\\end{verbatim}\n' + body = msg.get_body(preferencelist=('plain', 'html')) + for field in ['Date', 'From', 'To' 'Cc', 'Subject']: + h = msg.get(field) + if h: outstr += f'{field}: {h}\n' + outstr += '\n' + if frag == 'short': + outstr += shorten_mail(body.get_content()) + else: + outstr += body.get_content() + if mode == 'tex': + outstr += '\\end{verbatim}\n' # TODO merge this logic with the resolve file logic below for part in msg.iter_attachments(): -- cgit v1.2.3