Hi,
We are using aspose code for extracting attachments from msg file.
Environment : Java
Issue : An msg file with attachment name сканирование 2.pdf after saving is named as 2.pdf . Can you please help us with this.
Code :
String tempFilePath = "D:\\Test\\";
String fileName = "FW Tajik Air.msg";
int index=0;
//Instantiate an MSG file to load an MSG file from disk
MailMessage message = MailMessage.
load(tempFilePath + fileName, MessageFormat.getMsg());
MapiMessage mapiMessage=MapiMessage.fromMailMessage(message);
for (index = 0; index < message.getAttachments().size(); index++) {
MapiAttachment att = (MapiAttachment) mapiMessage.getAttachments().get(index);
System.out.println("Attachment Name: " + att.getLongFileName());
String strMSGAttachmentName = att.getLongFileName().replace('\\', ' ').replace('/', ' ')
.replace(':', ' ').replace('?', ' ').replace('*', ' ').replace('"', ' ').replace('<', ' ')
.replace('<', ' ').replace('>', ' ').replace('|', ' ');
att.save(tempFilePath + strMSGAttachmentName);
}
Files : Are Attached