use of javax.activation.URLDataSource in project pentaho-kettle by pentaho.
the class Mail method addAttachedFilePart.
private void addAttachedFilePart(FileObject file) throws Exception {
// create a data source
MimeBodyPart files = new MimeBodyPart();
// create a data source
URLDataSource fds = new URLDataSource(file.getURL());
// get a data Handler to manipulate this file type;
files.setDataHandler(new DataHandler(fds));
// include the file in the data source
files.setFileName(file.getName().getBaseName());
// insist on base64 to preserve line endings
files.addHeader("Content-Transfer-Encoding", "base64");
// add the part with the file in the BodyPart();
data.parts.addBodyPart(files);
if (isDetailed()) {
logDetailed(BaseMessages.getString(PKG, "Mail.Log.AttachedFile", fds.getName()));
}
}
Aggregations