List of usage examples for org.apache.commons.mail.resolver DataSourceFileResolver DataSourceFileResolver
public DataSourceFileResolver(final File baseDir)
From source file:com.pax.pay.trans.receipt.paperless.AReceiptEmail.java
public int sendHtmlEmail(EmailInfo emailInfo, String emailAddress, String subject, String content, Bitmap pic) { String placeHolder = "<img/>"; String htmlMsg = "<html><body>" + placeHolder + "</body></html>"; try {/* w w w. ja v a2s. c om*/ ImageHtmlEmail email = new ImageHtmlEmail(); setBaseInfo(emailInfo, email); File file = Convert(pic, "receipt_tmp.jpg"); email.setDataSourceResolver(new DataSourceFileResolver(file)); String cid = email.embed(file); // cid String img = "<img src='cid:" + cid + "'/>"; // img?cid htmlMsg = htmlMsg.replace(placeHolder, img); // ?html?? email.setSubject(subject); email.setTextMsg(content); email.setHtmlMsg(htmlMsg); email.addTo(emailAddress); email.send(); } catch (EmailException | IOException e) { e.printStackTrace(); return -1; } return 0; }