Hmm, we were just testing it and its strange since it works for me but fails for Gary. . . all on 2.2.
Can you please paste the code you use to retrieve message attachement?
Printable View
Hmm, we were just testing it and its strange since it works for me but fails for Gary. . . all on 2.2.
Can you please paste the code you use to retrieve message attachement?
This is the part where I process the message. The same code works fine in version 2.1.4.
It always throws an exception when accessing the input stream of the attachment.Code:public void receive(MimeMessage message) {
try {
Object content = message.getContent();
if (content instanceof Multipart) {
handleMultipart((Multipart) content);
}
} catch (Exception e) { }
}
private void handleMultipart(Multipart multipart)
throws MessagingException, IOException {
for (int i = 0, n = multipart.getCount(); i < n; i++) {
handlePart(multipart.getBodyPart(i));
}
}
private void handlePart(Part part) throws MessagingException, IOException {
try {
String disposition = part.getDisposition();
if (disposition != null
&& disposition.equalsIgnoreCase(Part.ATTACHMENT)) {
String fileName = part.getFileName();
String[] splitted = fileName.split("\\.");
if (splitted.length > 0 && this.fileEndingFilter
.contains(splitted[splitted.length - 1])) {
InputStream is = part.getInputStream();
File file = saveFile(fileName, is);
List<String> caseIds = this.etl.extractPatientData(file);
notifyChange(caseIds);
}
}
} catch (Exception e) { }
}
private File saveFile(String filename, InputStream input)
throws IOException {
String filePrefix = new Long(System.currentTimeMillis()).toString();
File file = new File(this.archiveDirectory + "/" + filePrefix + "-"
+ filename);
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
BufferedInputStream bis = new BufferedInputStream(input);
int aByte;
while ((aByte = bis.read()) != -1) {
bos.write(aByte);
}
bos.flush();
bos.close();
bis.close();
return file;
}
InputStream is = part.getInputStream();
Hi folks,
have u integrated the feature to search for old but unread messages already. If yes are there any examples where i could look up for a solution because if have exactly the same problem as described above. I could go with the proposed workaround but configuring it via XML would be the easiest way ;-)
Cheers Peter
Simply implement your own SearchTermStrategy. Take a look at DefaultSearchTermStrategy in ImapMailReceiver to see how the default strategy is implemented.
Then, provide a reference to your custom strategy to the adapter.