C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

C# Examples

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


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

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

 

 

 

 

 

 

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 .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

//  The mailman object is used for receiving (POP3)
//  and sending (SMTP) email.
Chilkat.MailMan mailman = new Chilkat.MailMan();

//  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.
Chilkat.Mht mht = new Chilkat.Mht();

//  Any string argument automatically begins the 30-day trial.
bool success;
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
    MessageBox.Show("MailMan component unlock failed");
    return;
}

success = mht.UnlockComponent("30-day trial");
if (success != true) {
    MessageBox.Show("Mht component unlock failed");
    return;
}

Chilkat.Email email = null;

mht.UseCids = true;
email = mht.GetEmail("http://www.bonairefishing.com/");
if (email == null ) {
    MessageBox.Show(mht.LastErrorText);
    return;
}

email.Subject = "Test HTML/plain-text email";

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

Chilkat.HtmlToText h2t = new Chilkat.HtmlToText();
success = h2t.UnlockComponent("Anything for 30-day trial");
if (success != true) {
    MessageBox.Show(h2t.LastErrorText);
    return;
}

//  Get the email's HTML body.
string html;
html = email.GetHtmlBody();

//  Convert it to plain text:
string plainText;
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 != true) {
    MessageBox.Show(mailman.LastErrorText);
    return;
}

MessageBox.Show("HTML/plain-text Email Sent!");


 

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

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

Email Component · XML Parser