ここに画像を添付して送信するコードがありますが、ローカルドライブから画像を読み込み、添付せずにメールの本文に埋め込みたいのですが、まだ解決策がありません。import org.apache.commons.mail.DefaultAuthenticator; に感謝します。org.apache.commons.mail.EmailAttachment をインポートします。org.apache.commons.mail.HtmlEmail をインポートします。
public class img {
public static void main(String[]args) throws Exception {
// Create the attachment
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("Monthly Target AchivedDaily.gif");
attachment.setDisposition(EmailAttachment.INLINE);
attachment.setDescription("Monthly");
attachment.setName("1");
HtmlEmail he = new HtmlEmail();
he.setSmtpPort(25);
he.setAuthenticator(new DefaultAuthenticator("myid","mypwd"));
he.setDebug(false);
he.setHostName("..com");
he.addTo("@.com","hsn");
//email.setSSL(true);
he.setFrom("mail", "Hassan");
he.setSubject("tst1");
he.attach(attachment);
he.send();
System.out.println("Done...");
}
}