diff --git a/mortgage_template.py b/mortgage_template.py index f31ae5d..dfa8260 100644 --- a/mortgage_template.py +++ b/mortgage_template.py @@ -203,7 +203,7 @@ def amortizeLoan(loan): def transformTemplate(template_fileName, loanModel): - # template_filename = "statement.txt.jinja" + # template_filename = "statement.text.jinja" # setup jinja for creating the statement env = Environment(loader=FileSystemLoader('.')) template = env.get_template(template_fileName) @@ -242,6 +242,30 @@ def generateEmail(from_address, to_address, subject, body, pdfAttachment, txtAtt return msg +def generateEmailWithAttachments(from_address, to_address, subject, body, pdfAttachment, htmlAttachment, txtAttachment): + msg = MIMEMultipart() + msg['Subject'] = subject + msg['From'] = from_address + msg['To'] = to_address + + msg.attach(MIMEText(body)) + + if (pdfAttachment != None): + part = MIMEBase("application", "octet-stream") + part.set_payload(pdfAttachment) + Encoders.encode_base64(part) + part.add_header('Content-Disposition', 'attachment; filename="statement.pdf"') + msg.attach(part) + + if (txtAttachment != None): + part = MIMEBase("text", "html") + part.set_payload(txtAttachment) + Encoders.encode_base64(part) + part.add_header('Content-Disposition', 'attachment; filename="statement.html"') + msg.attach(part) + + return msg + def sendEmail(msg, from_address, to_address, passwd): try: diff --git a/templates/add.html b/templates/add.html index 7e68337..78323fd 100644 --- a/templates/add.html +++ b/templates/add.html @@ -12,7 +12,11 @@
Web Mortgage Manager
- +| {{message}} |