Java Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Java Examples

Quick Start
Unicode
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
SFTP
Signatures
SMTP
Socket / SSL
Spider
SSH
SSH Key
SSH Tunnel
Tar
Upload
XML
XMP
Zip

More Examples...
Email Object
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Icon

 

 

 

 

 

 

 

Convert Web Page (URL) to HTML Email and Send

Download Chilkat Java Library

Uses CkMht to download a web page and all referenced images and CSS style sheets into a self-contained email and sends it.

import com.chilkatsoft.CkMht;
import com.chilkatsoft.CkMailMan;
import com.chilkatsoft.CkEmail;

public class EmailWebPage {
	
  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  // Downloads a web page and all embedded images and CSS style
  // sheets into a CkEmail object.
  // The web page converted to email is: 
  // http://www.chilkatsoft.com/testEmail/testEmail.html
  public static void main(String argv[]) 
  {
    CkMailMan mailman = new CkMailMan();
    mailman.UnlockComponent("anything for 30-day trial");
    
    // Set your SMTP server's hostname
    mailman.put_SmtpHost("smtp.comcast.net");
    
    // If your SMTP server requires a login, set username/password
    //mailman.put_SmtpUsername("myUsername");
    //mailman.put_SmtpPassword("myPassword");
    
    // Use MHT to load a web page and return an email object:
    CkMht mht = new CkMht();
    mht.UnlockComponent("anything for 30-day trial");
    
    CkEmail email = mht.GetEmail("http://www.chilkatsoft.com/testEmail/testEmail.html");
    
    // We still need a subject, and To/From
    email.put_Subject("Sending HTML e-mail from Java");
    email.put_From("Chilkat Support <support@chilkatsoft.com>");
    // Add a few recipients
    email.AddTo("Matt","matt@chilkatsoft.com");
    email.AddTo("TagTooga","admin@tagtooga.com");
    
    // Now send the HTML e-mail...
    boolean success = mailman.SendEmail(email);
    if (!success)
    {
    	mailman.SaveLastError("lastError.txt");	
    }
    
  }
}





 

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

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