这里是我的代码附加和发送图像,但我想加载图像形式本地驱动器并将其嵌入邮件正文而无需附加请帮助我,我搜索仍然没有解决方案。 谢谢 import org.apache.commons.mail.DefaultAuthenticator; import org.apache.commons.mail.EmailAttachment; import 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...");
}
}