Only 1 attachment from 4 (.NET)

Hello, there,
I read a mail with three attachments (and smime.p7b, technically four attachments) and get only one attachment in the attribute Attachments. The other attachments are not present.
My example code:
MapiMessage msg = MapiMessage.FromStream(filestream);
foreach (MapiAttachment mapiAttachment in msg.Attachments)
{
//
}

What to do? What is the solution?

uli

@uboddenberg,

Thank you for contacting Aspose Support.
It is requested to please share the sample email file so that we can investigate this scenario and share our feedback accordingly.

Testmail.zip (112.1 KB)
asposeemailissue.jpg (171.1 KB)
hello

I uploaded a test mail where I expect five attachments (four normal attachments and a smime.p7m file). As you can see on the also uploaded screenshot, the Aspose.Email component only has a single file,

uli

@uboddenberg,

You may read all attachments by loading the MSG file using MailMessage and then converting it to MapiMessage as shown in the sample given below. Please test the sample code and share your feedback with us.

MailMessage mailMessage = MailMessage.Load("Testmail.msg");
MapiMessage msg = MapiMessage.FromMailMessage(mailMessage);
foreach (MapiAttachment mapiAttachment in msg.Attachments)
{
    Console.WriteLine("File Name: " + mapiAttachment.FileName);
}

Moreover, we have logged a ticket in our issue tracking system as EMAILNET-39208 to investigate the attachment behavior of MapiMessage. We will update you here as soon as additional information is available.

Yeah, it works that way.
But there is now another problem: if there is an MSG object in the attachments , there is mapiAttachment.BinaryData==null. This can be seen in my example MSG file.
What is there to do?

uli

@uboddenberg,

Thank you for your feedback.

You may access the attached MSG file by saving it to MemoryStream as shown in the code snippet given below. Please test the sample code and share your feedback with us.

foreach (MapiAttachment mapiAttachment in msg.Attachments)
{
    if(mapiAttachment.MimeTag == "message/rfc822")
    {
        MemoryStream stream = new MemoryStream();
        mapiAttachment.Save(stream);
        MapiMessage mapi = MapiMessage.FromStream(stream);
        Console.WriteLine("Subject: " + mapi.Subject);
    }
}

The issues you have found earlier (filed as EMAILNET-39208) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by muhammadahmad