0

I want an email to be sent automatically. I am implementing this thing with the help of struts framework. I need to send an email where there will be an URL of a particular portal and the email body should contain a table with two columns but the number of rows is not fixed.

halfer
  • 19,824
  • 17
  • 99
  • 186
Mainak
  • 3
  • 1
  • 4

2 Answers2

2

Your email can be an HTML email. So you'd use HTML to implement the table, and set the email mime type headers accordingly.

This answer tells you how to set the mime type correctly.

Community
  • 1
  • 1
Rajesh J Advani
  • 5,585
  • 2
  • 23
  • 35
0

first create your table as in String format then set that String in setMsg()

 MultiPartEmail htmlEmail = new HtmlEmail();

        email.setSmtpPort(getPortNumber());
        // authenticating the user
        email.setAuthenticator(new DefaultAuthenticator(getSenderID(),
                getSenderPassword()));
        // email.setDebug(true);
        email.setSSL(true);
        //
        email.setTLS(true);
        // setting the host name
        email.setHostName(getHostName());
        // setting the rciever id

        email.addTo(receiverId);
        email.setFrom(getSenderID());
            // setting the subject of mail
        email.setSubject(getSubject());
        email.setMsg("<table border="1"><tr><td></td></tr>");//here is your html code
        email.send();
KhAn SaAb
  • 5,248
  • 5
  • 31
  • 52
  • Thank you guys for your quick response.I have used a while loop in my action class method and included that table inside that while loop.The table I created is simple html code inside the message body. – Mainak Jun 27 '13 at 08:27