markup: attach marked up pdf to email also

This commit is contained in:
2019-10-20 23:14:25 -07:00
parent 606f3fd5da
commit 1970e2f506
2 changed files with 10 additions and 4 deletions

View File

@ -12,8 +12,8 @@ log = logging.getLogger(__name__)
body_ok = """Hi,
Attached is a spreadsheet with the articles you marked up in the
catalog.
Attached is a copy of your marked up catalog and a spreadsheet with
the articles you selected.
Enjoy,
ProCatalog Markup Bot
@ -30,7 +30,7 @@ ProCatalog Markup Bot
"""
def reply(frm, subj, xls_path):
def reply(frm, subj, xls_path, pdf_path):
msg = EmailMessage()
msg.set_content(body_ok)
@ -40,6 +40,12 @@ def reply(frm, subj, xls_path):
subtype='vnd.openxmlformats-officedocument.spreadsheetml.sheet',
filename=Path(xls_path).name)
with open(pdf_path, 'rb') as fp:
msg.add_attachment(fp.read(),
maintype='application',
subtype='pdf',
filename=Path(pdf_path).name)
send(frm, subj, msg)

View File

@ -67,7 +67,7 @@ def process_attachment(from_address, subject, attachment):
if xls_path:
# send reply
print(f'wrote spreadsheet: {xls_path}')
reply(from_address, subject, xls_path)
reply(from_address, subject, xls_path, pdf_path)
else:
# send error
print(f'error creating spreadsheet')