How to handle inline image added by user in email client

88 views Asked by At

I am creating an online email client using JSF PrimeFaces and hibernate. User can compose email and send, A User should be able to add inline image in his email. All the code available on internet contains predefined image with defined source. some thing like this:

BodyPart messageBodyPart = new MimeBodyPart();
String htmlText = "Hello<img src=\"cid:image\">";
messageBodyPart.setContent(htmlText, "text/html");
multipart.addBodyPart(messageBodyPart);

// second part (the image)
messageBodyPart = new MimeBodyPart();
DataSource fds = new FileDataSource("/home/manisha/javamail-mini-logo.png");

messageBodyPart.setDataHandler(new DataHandler(fds));
messageBodyPart.setHeader("Content-ID", "<image>");

// add image to the multipart
multipart.addBodyPart(messageBodyPart);

// put everything together
message.setContent(multipart);
// Send message
Transport.send(message);

How I can handle an image the user adds by copying from some where from his drive and pasting in editor while writing email? I am using p:editor tag for writing message body.

0

There are 0 answers