markup: attach marked up pdf to email also
This commit is contained in:
@ -12,8 +12,8 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
body_ok = """Hi,
|
body_ok = """Hi,
|
||||||
|
|
||||||
Attached is a spreadsheet with the articles you marked up in the
|
Attached is a copy of your marked up catalog and a spreadsheet with
|
||||||
catalog.
|
the articles you selected.
|
||||||
|
|
||||||
Enjoy,
|
Enjoy,
|
||||||
ProCatalog Markup Bot
|
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 = EmailMessage()
|
||||||
msg.set_content(body_ok)
|
msg.set_content(body_ok)
|
||||||
|
|
||||||
@ -40,6 +40,12 @@ def reply(frm, subj, xls_path):
|
|||||||
subtype='vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
subtype='vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
filename=Path(xls_path).name)
|
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)
|
send(frm, subj, msg)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -67,7 +67,7 @@ def process_attachment(from_address, subject, attachment):
|
|||||||
if xls_path:
|
if xls_path:
|
||||||
# send reply
|
# send reply
|
||||||
print(f'wrote spreadsheet: {xls_path}')
|
print(f'wrote spreadsheet: {xls_path}')
|
||||||
reply(from_address, subject, xls_path)
|
reply(from_address, subject, xls_path, pdf_path)
|
||||||
else:
|
else:
|
||||||
# send error
|
# send error
|
||||||
print(f'error creating spreadsheet')
|
print(f'error creating spreadsheet')
|
||||||
|
|||||||
Reference in New Issue
Block a user