From b86eec0b2d1bd604a5e89eb80f061fadc35202da Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 16 Jan 2012 18:18:15 +0530 Subject: [PATCH] Ignore HTMLParseError while sending multipart email --- py/webnotes/utils/email_lib/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/py/webnotes/utils/email_lib/__init__.py b/py/webnotes/utils/email_lib/__init__.py index 4497055786..3cd722e04f 100644 --- a/py/webnotes/utils/email_lib/__init__.py +++ b/py/webnotes/utils/email_lib/__init__.py @@ -26,6 +26,7 @@ def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc from webnotes.utils.email_lib.html2text import html2text from webnotes.utils.email_lib.send import EMail + import HTMLParser email = EMail(sender, recipients, subject, reply_to=reply_to, from_defs=from_defs) email.cc = cc @@ -38,9 +39,12 @@ def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc if (not '
' in msg) or (not '

' in msg): msg = msg.replace('\n','
') footer = get_footer() - msg = msg + (footer or '') - email.set_text(html2text(msg)) - email.set_html(msg) + msg = msg + (footer or '') + try: + email.set_text(html2text(msg)) + except HTMLParser.HTMLParseError: + pass + email.set_html(msg) for p in parts: email.set_message(p[1]) for a in attach: