markup: attach marked up pdf to email also
This commit is contained in:
@ -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)
|
||||
|
||||
|
||||
|
||||
@ -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')
|
||||
|
||||
Reference in New Issue
Block a user