java2db

Example HTML file template for email in java



The mail API(Application Programing Interface) is used to send an email in both java stand alone and web applications.See the below example to create a HTML file template for email .

HTML file template for email in java Required Jar files :
HTML file template for email in java  mail.jar (Download mail.jar ) .

 

HTML file template for email in java Steps to send an email using HTML file template :

HTML file template for email in java  Create and design a HTML file with title and body (include keys for values).

HTML file template for email in java  Create a java file , write the logic to read HTML file content as a String value and replace the values

…..for the keys.

HTML file template for email in java  Add the mail.jar file to libraries , compile and run the application.

Note: specify the valid and exact  file path(Example: C:/mail/HTMLTemplate.html) of the HTML file .

 

HTML file template for email in java Example HTML file template for email :

HTMLTemplate.html  file have the designed body content of the mail .

The class emailWithHTMLTemplate calls the HTML file to create the body content of the email.

The Mail looks like below.
HTML file template for email in java

 

Create your own HTML file template for email based on your design requirements.

Common SMTP servers : Some of the common SMTP servers are listed below.

Mail Service Server Host Port
Gmail smtp.gmail.com 587
Yahoo Mail smtp.mail.yahoo.com 587
Hotmail smtp.live.com 25
Rocketmail smtp.mobile.mail.yahoo.com 25



Related Posts :
Send html email in java with cc , bcc , image and attachment

Comments

  1. hime trivedi says:

    Hey

    I am able to send email successfully but css is not getting loaded in mail.Please help me.

    Regards
    Himen

    • Seetaram says:

      Hi , its better to use inline styles to store all of your style information.
      Example : replace <table style=”background-color:#008000″ width=”10″> for <table bgcolor=”#008000″ width=”100%”> tag.
      If you use external stylesheet link in <head> tag,the email client may block it.

   [will not be published]



^ <