Why won't Outlook use the text/plain part?

╄→гoц情女王★ 提交于 2019-12-10 10:19:43

问题


First of all, hello,

With SwiftMailer, i'm sending HTML+PLAIN emails.

On outlook, when displaying this email as plain text, this is not my plain text part showing up, but a automatic parsed version of the HTML.

Does anyone know how to force Outlook to use the text/plain part of message when displaying plain text?

My code does the following:

$plain_body = convert_html_to_text($body);
$message->setBody($body, 'text/html')
->addPart($plain_body, 'text/plain');

$body has some formatting and images:

vardump($body);

<html>
<head>...</head>
<body>
<img src="logo.png" alt="Company name" /><br />
<img src="border.png" alt="border" /><br />
<img src="face.png" alt="Mr Somebody" /><br />
<p>Hello Ninj!

You requested a confirmation by email...</p>
<img src="footer.png" alt="footer" />
</body></html>

$plain_body contains a very clean text (thanks javon):

vardump($plain_body);

"Hello Ninj!

You requested a confirmation by email..."

But in the plain text version viewed in Outlook, i see instead all the alt attributes of pics of the HTML version, one by line, then some lightly formatted text:

Company Name

border

Mr Somebody

Hello Ninj!

You requested a confirmation by email...

Footer

Thank you by advance for everyone able to help :)


回答1:


Can't do that. Outlook keeps all 3 body flavors (HTML, RTF, plain text) in sync. This is done on the store provider level.

When it receives a MIME message, it uses the HTML body (if available). When the message is saved, the store provider uses the HTML body to generate the plain text body (PR_BODY property).



来源:https://stackoverflow.com/questions/19135443/why-wont-outlook-use-the-text-plain-part

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!