VB.NET Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++DelphiFoxProJavaPerlPythonRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Byte Array
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

Type Conversion

 

Article: Understanding COM References in Delphi

Convert Email HTML to Plain-Text Alternative

Loads an HTML email from a web page, converts the HTML to a plain-text alternative body, and sends it.

Download Chilkat Email ActiveX

Download Chilkat HTML-to-XML ActiveX (also includes HTML-to-PlainText conversion)

Download Chilkat MHT ActiveX

uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls,
    CHILKATMAILLib2_TLB,
    HTMLTOXMLLib_TLB,
    CHILKATMHTLib_TLB,
    OleCtrls;

...

procedure TForm1.Button1Click(Sender: TObject);
var
mailman: TChilkatMailMan2;
mht: TChilkatMht;
success: Integer;
email: CHILKATMAILLib2_TLB.IChilkatEmail2;
h2t: THtmlToText;
html: String;
plainText: String;

begin
//  The mailman object is used for receiving (POP3)
//  and sending (SMTP) email.
mailman := TChilkatMailMan2.Create(Self);

//  The MHT component can be used to convert an HTML page
//  from a URL, file, or in-memory HTML into an email
//  with embedded images and style sheets.
mht := TChilkatMht.Create(Self);

//  Any string argument automatically begins the 30-day trial.
success := mailman.UnlockComponent('30-day trial');
if (success <> 1) then
  begin
    ShowMessage('MailMan component unlock failed');

  end;

success := mht.UnlockComponent('30-day trial');
if (success <> 1) then
  begin
    ShowMessage('Mht component unlock failed');

  end;

mht.UseCids := 1;
email := mht.GetEmail('http://www.bonairefishing.com/');
if (email = nil ) then
  begin
    ShowMessage(mht.LastErrorText);

  end;

email.Subject := 'Test HTML/plain-text email';

email.AddTo('Chilkat Support','support@chilkatsoft.com');
email.From := 'admin@chilkatsoft.com';

h2t := THtmlToText.Create(Self);
success := h2t.UnlockComponent('Anything for 30-day trial');
if (success <> 1) then
  begin
    ShowMessage(h2t.LastErrorText);

  end;
//  Get the email's HTML body.

html := email.GetHtmlBody();

//  Convert it to plain text:

plainText := h2t.ToText(html);

//  Add a plain-text alternative to the email:
email.AddPlainTextAlternativeBody(plainText);

mailman.SmtpHost := 'mail.chilkatsoft.com';
mailman.SmtpUsername := 'admin@chilkatsoft.com';
mailman.SmtpPassword := '*myPassword5*';

success := mailman.SendEmail(email);
if (success <> 1) then
  begin
    ShowMessage(mailman.LastErrorText);

  end;

ShowMessage('HTML/plain-text Email Sent!');


end;

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · XML Parser