1 issue in MailMessage - 2 issues in both MailMessage and MapiMessage

Hello
Loading the attached msg file into MailMessage will cause InvalidOperationException
While loading it into the MapiMessage will not throw any exception

Anyway, both MailMessage and MapiMessage will have problems when using:
For Each xx In MyMapiMessage.Attachments
MsgBox(xx.DisplayName)
Next

Many NullReferenceException
Attachments are not loaded correctly!

WindowsApplication24.zip (3.9 MB)

@australian.dev.nerds,

You use TnefLoadOptions to load into the MailMessage!

The attachment does not have a DisplayName property value.

var s = msg.Attachments[0].Properties[KnownPropertyList.DisplayName].GetString(); // returns null
1 Like

Hello,

oops, so sorry, shameful, using New MsgLoadOptions into MailMessage will load it, and will show no attachments.

While MapiMessage will find some attachment, but:
0.png (29.1 KB)

Just wonder if this is normal? thanks :slight_smile:

@australian.dev.nerds,

This is normal, because the attachment is an embedded object. In this case, its data is in the ObjectData property that represents the PidTagAttachDataObject MAPI property.