Send email with attachment and using template in java

Sunday, July 24th, 2016 (0 Comment)

In Sending gmail or mail in java article, we have known basic about sending email by use gmail or your host mail in java.

Continue, we will find more detail about Send email with attachment and using template in java. In here, we will use HTML template file.

We need to create read file html method with content includes some {{keyword}} and after replace it in sending email method.

1. Create a template html file

  • Line 13 – 15: parameters will be replace is : {{username}}, {{firstname}}, {{lastname}}

2. Send email using template in java

– Create function to read file’s content

– Create function to set parameters, it will replace {{keyword}} in html file

– Main function: using your host mail

  • Line 41 – 43: input paramters in template html file

3. Send email with attachment in java

– Main function Send email with attachment: using your host mail

– Above, we use personal host mail to Send email with attachment, If you use gmail host to Send email with attachment and using template, you can review Sending gmail or mail in java and replace some config in main function.

 

Tags: , , , , , ,

Related Posts

core java
Export Crystal Report with Subreport in java
core java
Convert xml to object java and vice versa
core java
Java basic tutorial on lvtutorial.com
core java
Java hibernate manytomany to manage user role

Related Posts

core java
Export Crystal Report with Subreport in java
core java
Convert xml to object java and vice versa
core java
Java basic tutorial on lvtutorial.com
core java
Java hibernate manytomany to manage user role

Leave a Reply

Your email address will not be published. Required fields are marked *