这是我的附加和发送图像的代码,但我想从本地驱动器加载图像并将其嵌入邮件正文而不附加请帮助我,我搜索了仍然没有解决方案。感谢导入 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...");
}
}