code: private static BodyPart getBodyPartFromDatasource(final AttachmentResource attachmentResource, final String dispositionType)
  			throws MessagingException {
  		final BodyPart attachmentPart = new MimeBodyPart();
  		// setting headers isn't working nicely using the javax mail API, so let's do that manually
  		final String resourceName = determineResourceName(attachmentResource, false);
  		final String fileName = determineResourceName(attachmentResource, true);
  		attachmentPart.setDataHandler(new DataHandler(new NamedDataSource(fileName, attachmentResource.getDataSource())));
  		attachmentPart.setFileName(fileName);
  		final String contentType = attachmentResource.getDataSource().getContentType();
  		attachmentPart.setHeader("Content-Type", contentType + "; filename=" + fileName + "; name=" + resourceName);
  		attachmentPart.setHeader("Content-ID", format("<%s>", resourceName));
  		attachmentPart.setDisposition(dispositionType);
  		return attachmentPart;
  	}
docs: Helper method which generates a {@link BodyPart} from an {@link AttachmentResource} (from its {@link DataSource}) and a disposition type
  ({@link Part#INLINE} or {@link Part#ATTACHMENT}). With this the attachment data can be converted into objects that fit in the email structure.
  <p>
  For every attachment and embedded image a header needs to be set.
  
  @param attachmentResource An object that describes the attachment and contains the actual content data.
  @param dispositionType    The type of attachment, {@link Part#INLINE} or {@link Part#ATTACHMENT} .
  
  @return An object with the attachment data read for placement in the email structure.
  @throws MessagingException All BodyPart setters.