Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

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


More Examples...
Email Object
POP3
SMTP
RSS
Atom
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 C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

#include <CkMailMan.h>
#include <CkMht.h>
#include <CkEmail.h>
#include <CkHtmlToText.h>

void ChilkatSample(void)
    {
    //  The mailman object is used for receiving (POP3)
    //  and sending (SMTP) email.
    CkMailMan 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.
    CkMht mht;

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

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

    CkEmail *email = 0;

    mht.put_UseCids(true);
    email = mht.GetEmail("http://www.bonairefishing.com/");
    if (email == 0 ) {
        printf("%s\n",mht.lastErrorText());
        return;
    }

    email->put_Subject("Test HTML/plain-text email");

    email->AddTo("Chilkat Support","support@chilkatsoft.com");
    email->put_From("admin@chilkatsoft.com");

    CkHtmlToText h2t;
    success = h2t.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        printf("%s\n",h2t.lastErrorText());
        return;
    }

    //  Get the email's HTML body.
    const char * html;
    html = email->getHtmlBody();

    //  Convert it to plain text:
    const char * plainText;
    plainText = h2t.toText(html);

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

    mailman.put_SmtpHost("mail.chilkatsoft.com");
    mailman.put_SmtpUsername("admin@chilkatsoft.com");
    mailman.put_SmtpPassword("*myPassword5*");

    success = mailman.SendEmail(*email);
    if (success != true) {
        printf("%s\n",mailman.lastErrorText());
        return;
    }

    delete email;

    printf("HTML/plain-text Email Sent!\n");


    }

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

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

Mail Component · .NET Mail Component · XML Parser