I want to embed a link in email for file already attached in email message using JavaMail API.
For example, I am sending an email with some attachments. Now I want to embed link for all files which are available in email message.
Could you please help me on this?
I am using below code to attach a file in email message:
MimeBodyPart messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(attachFile);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(attachFileName);
Setup attachment as following code:
MimeBodyPart messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(attachFile);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setHeader("Content-ID","file");
messageBodyPart.setFileName(attachFileName);
In the above code Content-ID is defined as file which can used as reference in href of anchor tag as:
<a href='cid:html'>link text</a>