Aspose Team,
Using the Java Aspose 19.6 email libraries, we’re trying to extract the attachments from an EML and save the attachments with their given names. However, when the attachment name contains non-English characters, we’re seeing the Aspose attachment save API method throw a “FileNotFoundException”.
Here’s a sample bit of code meant to show the relevant pieces:
Path filePath = getFilePath(); // input EML file with attachment (see attached sample file)
Path destFolderPath = getDestinationPath();
// Instantiate a mail message object to load the EML file from disk
MailMessage msg = MailMessage.load(filePath.toString());
for (int i = 0; i < msg.getAttachments().size(); i++) {
Attachment attachment = msg.getAttachments().get_Item(i);
String fileName = attachment.getName();
File file = new File(destFolderPath.toFile(), fileName);
try {
attachment.save(file.toString());
} catch (FileNotFoundException ex) {
Logger.Log(“Aspose failed to save attachment '” + fileName + " to " + file);
}
}
O.PC.00000780.zip (2.7 KB)
I’ve attached an EML file that exhibits the problem that we’re seeing. Please advise.
Thanks for your help.
Jerry