Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Convert Web Page (URL) to HTML Email and SendUses 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.