Re: HTML to text
- From: Craig <craigvn@xxxxxxxxx>
- Date: Tue, 25 Apr 2006 09:47:23 +1000
I am looking for a already done object for Delphi 2005/2006 that converts
HTML formated e-mail bodies to the raw text, it just removes the HTML
formatting codes. Anybody have any idea? It can be shareware or commerical.
If you recommend something, please give me an idea why it is great and any
known drawbacks on it. Thanks in advance!
Try
function HtmlToText(const Html: string): string;
var
WebBrowser: TWebBrowser;
Document: IHtmlDocument2;
Doc: OleVariant;
v: Variant;
Body: IHTMLBodyElement;
TextRange: IHTMLTxtRange;
begin
Result := '';
WebBrowser := TWebBrowser.Create(nil);
try
Doc := 'about:blank';
WebBrowser.Navigate2(Doc);
Document := WebBrowser.Document as IHtmlDocument2;
if (Assigned(Document)) then
begin
v := VarArrayCreate([0, 0], varVariant);
v[0] := Html;
Document.Write(PSafeArray(TVarData(v).VArray));
Document.Close;
Body := Document.body as IHTMLBodyElement;
TextRange := Body.createTextRange;
Result := TextRange.text;
end;
finally
WebBrowser.Free;
end;
end;
.
- References:
- HTML to text
- From: Barton Stano
- HTML to text
- Prev by Date: Re: updated Delphi FastZlib 1.2.3
- Next by Date: Re: Sleuth QA
- Previous by thread: Re: HTML to text
- Next by thread: Re: HTML to text
- Index(es):
Relevant Pages
|