Aspose.Email does not seem to be able to read named properties of embedded messages correctly

Aspose.Email does not seem to be able to read named properties of embedded messages correctly.

Consider this code:

MapiMessage message = MapiMessage.Load("c:\temp\message.msg", new MsgLoadOptions());

var namedPropertiesForParent = message.NamedProperties;

MapiMessage embeddedMessage = message.Attachments[0].ObjectData.ToMapiMessage();

var namedPropertiesForEmbeddedMessage = embeddedMessage.NamedProperties;

The message in "c:\temp\message.msg" has named properties and it also contains an embedded message that also contains named properties.

Aspose correctly reads the named properties of the parent message, but not the embedded one.

The namedPropertiesForEmbeddedMessage variable in this case would be an empty collection.

The named properties appear in embeddedMessage.Properties. Their IsNamed property value will be true. But there is no way to get the named property names correctly. Also, we should be able to use the NamedProperties property to access them.

The bug is in Aspose.Email 18.9 but it also exists in previous versions.

I attach the sample message file.

message.zip (8.7 KB)

@bahakh,

We were able to reproduce the issue that you reported. A ticket has been logged in our issue tracking system against it as EMAILNET-39137. We will update you as soon as additional information is available.

@bahakh,

The attachment’s ObjectData does not contain named properties. To access the named properties of the embedded message, you need to save it separately as shown the code snippet given below.

MapiMessage message = MapiMessage.Load(@"message.msg", new MsgLoadOptions());
var namedPropertiesForParent = message.NamedProperties;
using (MemoryStream ms = new MemoryStream())
{
    message.Attachments[0].Save(ms);
    MapiMessage embeddedMessage = MapiMessage.FromStream(ms);
    var namedPropertiesForEmbeddedMessage = embeddedMessage.NamedProperties;
}

We hope that this resolved the issue that you were facing. Please feel free to reach us if additional information is required.