Msg inside msg with empty subject has null file name

Hi,


I’ve loaded a msg file which has another msg file attached to it using the MapiMessage class (see attachment test1.zip).
The internal msg file has an empty email subject. When the attachment is processed using the MapiAttachment class the attachment filename, long file name and extension are all null.

MailMessage origMessage = MailMessage.load( “C:\Temp\test1.msg” ), MessageFormat.getMsg());

for (int i = 0; i < origMessage.getAttachments().size(); i++)
{
MapiAttachment attachment = (MapiAttachment) origMessage.getAttachments().get(i);

System.out.prinln(attachment.getLongFileName());
System.out.prinln(attachment.getFileName());
System.out.prinln(attachment.getExtension());

}

The three prinln calls above show that LongFileName, FileName and Extension are null. I need to determine file extension to do some some selective processing of the attachments.

If the msg file is opened in Outlook you can see that the internal msg attachment has the name 'Untitled.msg'. Why isn't this being returned for the file name?


Thanks & regards,




chEmailTest:
MailMessage origMessage = MailMessage.load( "C:\\Temp\\test1.msg" ), MessageFormat.getMsg());

for (int i = 0; i < origMessage.getAttachments().size(); i++)
{
MapiAttachment attachment = (MapiAttachment) origMessage.getAttachments().get(i);

System.out.prinln(attachment.getLongFileName());
System.out.prinln(attachment.getFileName());
System.out.prinln(attachment.getExtension());

}
Hi,

Your provided source code is incorrect and it throws java.lang.ClassCastException because you are loading the message into an instance of MailMessage and casting it's attachment to MapiAttachment. I believe you meant the source code as give below,
Java
MapiMessage origMessage = MapiMessage.fromFile( "test1.msg"); for (int i = 0; i < origMessage.getAttachments().size(); i++) { MapiAttachment attachment = (MapiAttachment) origMessage.getAttachments().get(i); System.out.println(attachment.getLongFileName()); System.out.println(attachment.getFileName()); System.out.println(attachment.getExtension()); }

I can confirm, if your message is loaded into an instance of MapiMessage then the attachment properties like LongFileName, FileName and Extension are Null. To investigate this issue, I have logged a ticket (NETWRKJAVA-33133) in our bug tracking system.


We will soon sort this out and will keep you posted with updates.
Regards,

Sorry that was a typo, the first line should be:


MapiMessage origMessage = MapiMessage.fromFile(“C:\Temp\test1.msg”);


The issues you have found earlier (filed as NETWRKJAVA-33133) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.