I’m using an IdImap4 + Idmessage to receive emails.
But I couldn’t find out:
- how to display a received HTML formatted email body on a TWebBrowser?
- wether it is possible to show the simple text messages on a TWebBrowser, too? If yes, how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is technically possible to display an email’s HTML, however
TWebBrowseris not really well-suited for this purpose. You need to store the HTML in memory that is accessible via anIStreaminterface (such as by using theTMemoryStreamandTStreamAdapterclasses), then navigate the browser to the"about:blank"URL via theTWebBrowser::Navigate2()method and wait for theTWebBrowser::OnDocumentCompleteevent to fire, then query the document for itsIPersistStreamInitinterface and pass theIStreamto theIPersistStreamInit::Load()method.There are subtle quirks with displaying in-memory HTML in general, let alone displaying HTML from an email. In particular, the email’s HTML may have dependancies on images and other resources that are located elsewhere in the email, which cannot be loaded in
TWebBrowserwithout saving them to temp files and altering the HTML to refer to them. You are better off using a third-party HTML viewer, such as the HTML viewing components from http://www.pbear.com, that support manually providing the data for requested resources. Then you can pull the data from theTIdMessageas needed.To display other messages in the browser, you will likely have to manipulate the document’s DOM after the initial page is loaded (unless you alter the HTML inline before displaying it).