0

我想自动发送一封电子邮件。我在 struts 框架的帮助下实现了这个东西。我需要发送一封电子邮件,其中将包含特定门户的 URL,并且电子邮件正文应包含一个包含两列的表,但行数不固定。

4

2 回答 2

2

您的电子邮件可以是 HTML 电子邮件。因此,您将使用 HTML 来实现表格,并相应地设置电子邮件 mime 类型标题。

此答案告诉您如何正确设置 mime 类型。

于 2013-06-17T09:40:42.343 回答
0

首先以字符串格式创建您的tableas 然后将该字符串设置为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();
于 2013-06-17T10:02:49.100 回答