Message body returns html without angle brackets <>
Message body returns html without angle brackets <>
Hi team, I tried get message content from the my mail box, code is very simple
for message in account.inbox.all():
print(message.body)
But I sometimes get a html content without the brackets.
When I check the mailbox, I find the content body is displaying correctly just like a working html page. Is there something wrong with the way to retrieve the body as html?
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"!-- BaNnErBlUrFlE-BoDy-start --!-- Preheader Text : BEGIN --htmlheadmeta http-equiv="Content-Type" content="text/html; charset=utf-8"/headbodydiv style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;"Deal landscape in Asia on 26 August 2022 /div!-- Preheader Text : END --!-- Email Banner : BEGIN --div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;"ZjQcmQRYFpfptBannerStart/div!--[if ((ie)|(mso))] table border="0" cellspacing="0" cellpadding="0" width="100%" style="padding: 16px 0px 16px 0px; direction: ltr" lang="en"trtd table border="0" cellspacing="0" cellpadding="0" style="padding: 0px 10px 5px 6px; width: 100%; border-radius:4px; border-top:4px solid #c96fcd;background-color:#490E4B;"trtd valign="top" table align="left" border="0" cellspacing="0" cellpadding="0" style="padding: 4px 8px 4px 8px" trtd style="color:#000000; font-family: 'Arial', sans-serif; font-weight:bold; font-size:14px; direction: ltr" font color="#FFFFFF"This Message Is From an External Sender/font /td/tr trtd style="color:#000000; font-weight:normal; font-family: 'Arial', sans-serif; font-size:12px; direction: ltr" /td/tr /table /td/tr/table /td/tr/table![endif]--![if !((ie)|(mso))]div dir="ltr" lang="en" id="pfptBannerwxonye9" style="all: revert !important; display:block !important; text-align: left !important; margin:16px 0px 16px 0px !important; padding:8px 16px 8px 16px !important; border-radius: 4px !important; min-width: 200px !important; background-color: #490E4B !important; background-color: #490E4B; border-top: 4px solid #c96fcd !important; border-top: 4px solid #c96fcd;"div id="pfptBannerwxonye9" style="all: unset !important; float:left !important; display:block !important; margin: 0px 0px 1px 0px !important; max-width: 600px !important;"div id="pfptBannerwxonye9" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #490E4B !important; color:#000000 !important; color:#000000; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-weight:bold !important; font-weight:bold; font-size:14px !important; line-height:18px !important; line-height:18px"font color="#FFFFFF"This Message Is From an External Sender/font /divdiv id="pfptBannerwxonye9" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #490E4B !important; color:#000000 !important; color:#000000; font-weight:normal; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-size:12px !important; line-height:18px !important; line-height:18px; margin-top:2px !important;"/div/divdiv style="clear: both !important; display: block !important; visibility: hidden !important; line-height: 0 !important; font-size: 0.01px !important; height: 0px"nbsp;/div/div![endif]div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;"ZjQcmQRYFpfptBannerEnd/div!-- Email Banner : END --!-- BaNnErBlUrFlE-BoDy-end --!-- BaNnErBlUrFlE-HeAdEr-start --style #pfptBannerwxonye9 { all: revert !important; display: block !important; visibility: visible !important; opacity: 1 !important; background-color: #490E4B !important; max-width: none !important; max-height: none !important } .pfptPrimaryButtonwxonye9:hover, .pfptPrimaryButtonwxonye9:focus { background-color: #903994 !important; } .pfptPrimaryButtonwxonye9:active { background-color: #c96fcd !important; }/style!-- BaNnErBlUrFlE-HeAdEr-end --!-- NAME: 1:3 COLUMN --!--[if gte mso 15] xml o:OfficeDocumentSettings o:AllowPNG / o:PixelsPerInch96/o:PixelsPerInch /o:OfficeDocumentSettings /xml ![endif]--meta http-equiv="x-ua-compatible" content="IE=edge"meta name="viewport" content="width=device-width, initial-scale=1"titleDeal landscape in Asia on 26 August 2022/titlestyle type="text/css" p{ margin:10px 0; padding:0; } table{ border-collapse:collapse; } h1,h2,h3,h4,h5,h6{ display:block; margin:0; padding:0; } img,a img{ border:0; height:auto; outline:none; text-decoration:none
...... pure html is too long so have to cut here ........
/tr /table ![endif]--/td/tr/tbody/table/td/tr/tbody/table!--[if (gte mso 9)|(IE)] /td /tr /table ![endif]--!-- // END TEMPLATE --/td/tr/tbody/table/centerimg src="https://dealstreetasia.us9.list-manage.com/track/open.php?u=d5da2f287ddffd73e774cd522amp;id=4119171df6amp;e=17710faef7" height="1" width="1" alt="" /body/html
Expected behavior I want to see a html text with the angle brackets <> so that I can parse the email
Thanks very much
This looks like either a bug in Exchange, or a malformed email message that Outlook / OWA is able to render properly anyway.
If you enable debug logging you should be able to see if the email body is returned by the EWS API with or without brackets.
@alphafan Did you get around to debugging this?
Closing. Feel free to reopen if you get time to collect the additional information.