// decide, if to take content from source or plain text
// from variable to build mailbody
String messageString;
if (this.bodyURI != null) {
Source inSrc = resolver.resolveURI(this.bodyURI);
this.usedSources.add(inSrc);
InputStream inStr = inSrc.getInputStream();
byte[] byteArr = new byte[inStr.available()];
inStr.read(byteArr);
messageString = new String(byteArr);
// String mailBody = new String(byteArr);
// this.setMessageBody(messageBodyPart, mailBody, this.bodyMimeType);
} else {
messageString = this.body;
// this.setMessageBody(messageBodyPart, this.body, this.bodyMimeType);
}
// make it a simple plain text message in the case of a set plain/text
// mime-type and any attachements
if("text/plain".equals(this.bodyMimeType) && this.attachments.size() == 0) {
sm.setText(messageString);
}
// add message as message body part
else {
messageBodyPart.setContent(messageString, this.bodyMimeType);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// process attachments
Iterator i = this.attachments.iterator();
while (i.hasNext()) {
AttachmentDescriptor aD = (AttachmentDescriptor) i.next();
messageBodyPart = new MimeBodyPart();
if (!aD.isTextContent()) {
Source inputSource = resolver.resolveURI(aD.isURLSource() ? aD.strAttrSrc : aD.strAttrFile);
this.usedSources.add(inputSource);
DataSource dataSource = new SourceDataSource(inputSource, aD.strAttrMimeType, aD.strAttrName);
messageBodyPart.setDataHandler(new DataHandler(dataSource));