MapiAttachment.ObjectData Returns Null for Valid Outlook Message Attachments

Hi Team,

MapiAttachment.ObjectData property returns null for certain valid Outlook message attachments (.msg files), causing our application to fail in processing embedded messages consistently.

  • Aspose.Email Version: 24.3.0
  • Framework: .NET Framework 4.7.2

We are experiencing inconsistent behavior when processing nested MSG file attachments using MapiMessage.Load() and MapiAttachment.ObjectData . For some emails, ObjectData is null even when the attachment is a valid Outlook message file, while for others it works correctly.

Code Snippet
using (var currentMessage = Aspose.Email.Mapi.MapiMessage.Load(currentFilePath))
{
foreach (MapiAttachment attachment in currentMessage.Attachments)
{
if (!attachment.IsInline)
{
// Issue: ObjectData is null for some valid .msg attachments
if (attachment.ObjectData != null && attachment.ObjectData.IsOutlookMessage)
{
// Processing attachment - this block is never reached for Email_1
// … further processing
}
else
{
// Email_1 attachment falls into this branch unexpectedly
Console.WriteLine($“ObjectData is null for: {attachment.DisplayName}”);
}
}
}
}

Test Cases

Email_1 (Issue Case):

  • File: Fw_ Test email.msg
    Fw_ Test email.zip (1.1 MB)

  • Attachment: Wire Transfers - Mock up #4.msg (1 attachment)

  • Problem: attachment.ObjectData returns null

  • Expected: attachment.ObjectData should not be null and IsOutlookMessage should be true

Email_2 (Working Case):

  • File: Wire Transfers - Mock up #4.msg
    Wire Transfers - Mock up #4.zip (1.1 MB)

  • Attachments:

    • Wire Transfers - Mock up #1.msg
    • Wire Transfers - Mock up #2.msg
    • Wire Transfers - Mock up #3.msg
  • Behavior: attachment.ObjectData is not null and IsOutlookMessage returns true

  • Result: Works as expected

Thanks,
Subbu

Hello @subramanyam.gvsrb,

Thank you for providing the detailed description and test samples.

The behavior you are observing is expected and is related to how Outlook internally stores different types of attachments in MSG files.

In Fw_ Test email.msg, the attachment Wire Transfers - Mock up #4.msg is indeed a valid .msg file. However, it is not stored as an embedded Outlook object. Instead, its data is stored in the MAPI property PidTagAttachDataBinary.
Because of this, the attachment is treated as a binary file attachment, not as an embedded Outlook message object. So, the MapiAttachment.ObjectData property remains null, which is expected behavior.

In your second example (Wire Transfers - Mock up #4.msg), the nested .msg attachments are stored using PidTagAttachDataObject, which means they are embedded Outlook message objects.

The ObjectData property is only populated when the attachment is stored as an embedded object using the MAPI property PidTagAttachDataObject.

If you need to process .msg attachments regardless of how they are stored, you should handle the binary attachment case as well.
For example, when ObjectData is null, you can read the attachment content from the binary data.

need one help.
in Outlook how to attach the emails in below two ways.

  1. the attachment is stored as embeded Outlook object
  2. the attachment is stored in Mapi Property PidTagAttachDataBinary.

@subramanyam.gvsrb,

Attachment stored as Embedded Outlook Object

This is used when you attach another Outlook item (like an email, meeting request, task, or contact) inside an email.

Method 1 - Drag & Drop:

  1. Open the new email.
  2. Drag an email from your inbox into the message body.
  3. It becomes an embedded Outlook item.

Method 2 — Insert Outlook Item:

  1. New Email.
  2. Click Insert → Outlook Item.
  3. Choose the message or item to attach.

Attachment stored in PidTagAttachDataBinary

This is the standard file attachment type (PDF, DOCX, ZIP, images, etc.).

  1. New Email
  2. Click Attach File
  3. Select any file.