html - Microsoft Outlook python new line character -


i trying figure out how send output python script outlook mailbox. i'm having issues formatting. original method below

def email_mailbox(file_checked, error_list):     error_msg = ''     e in error_list:         if e not none:             e += '\n'             error_msg += e     if len(error_msg) > 1:         error_msg += '\nautomated test result: failed'     else:         error_msg = 'automated test result: passed'     msg = mimetext(error_msg)     msg['subject'] = 'automated review ' + file_checked[:-6]     msg['from'] = 'a'     msg['to'] = 'b'     s = smtplib.smtp('smlsmtp')     s.sendmail('a', 'b', msg.as_string())     s.quit()     print(file_checked + ' review email sent') 

the problem unknown reason me when send large amounts of output, lines not displayed on new line

enter image description here

using note pad open email address can see formatting looks ok

ubnzi91d not start p<br>  ubnzi09m not start p<br>  ubnzc66d not start p<br> ubnzc66d quantitative resources not correct<br>  ubnzc67d not start p<br>  ubnzc67d quantitative resources not correct<br>  ubnzc68d not start p<br>  ubnzc68d quantitative resources not correct<br>  ubnzc69d not start p<br>  ubnzc69d quantitative resources not correct<br>  ubnzf08d not start p<br> ubnzend1 not start p<br> 

my python skills ok , im pretty sure encoding problem life of me cant figure why not formatting correctly. have tried

for e in error_list:     if e not none:         new_line = '<br>'         new_line.encode('ascii', 'xmlcharrefreplace')         e += new_line         error_msg += e 

which found here http://beckism.com/2009/03/named_entities_python/ no luck. reading plain text of normal text email sent in outlook, find following

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta name="generator" content="ms exchange server version 14.03.0162.000"> <title>test 2</title> </head> <body> <!-- converted text/plain format -->  <p><font size=2>new line<br> new line<br> <br> cheers,<br> <br> 

any appreciated in mystery

consider automating outlook preferred programming language instead. see how automate outlook program , c# app automates outlook (csautomateoutlook). chapter 17: working item bodies article in msdn describes possible ways of working message bodies.

be aware, microsoft not recommend, , not support, automation of microsoft office applications unattended, non-interactive client application or component (including asp, asp.net, dcom, , nt services), because office may exhibit unstable behavior and/or deadlock when office run in environment.

if building solution runs in server-side context, should try use components have been made safe unattended execution. or, should try find alternatives allow @ least part of code run client-side. if use office application server-side solution, application lack many of necessary capabilities run successfully. additionally, taking risks stability of overall solution. see considerations server-side automation of office more information.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -