generateSAXReportStatements(iA);
}
private Message setUpMessage(Session session) throws Exception {
Message sm = new MimeMessage(session);
//sm.setAllow8bitMIME(true);
Address[] replyTo = new Address[this.replyToAddresses.size()];
for (int i = 0 ; i < this.replyToAddresses.size(); i++) {
replyTo[i] = new InternetAddress((String) this.replyToAddresses.get(i));
}
sm.setReplyTo(replyTo);
sm.setFrom(new InternetAddress(this.fromAddress));
sm.setSubject(this.subject);
// process mail-body
BodyPart messageBodyPart = new MimeBodyPart();
// 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));
} else {
messageBodyPart.setContent(aD.strContent, aD.strAttrMimeType);
}
messageBodyPart.setFileName(aD.strAttrName);
multipart.addBodyPart(messageBodyPart);
}
sm.setContent(multipart);
}
//sm.setReturnOption(SMTPMessage.RETURN_FULL);
sm.saveChanges();
return sm;
}