Oledata.mso attachments

using this code:

        new License().SetLicense(GetEmbeddedLicenseFile("Aspose.Total.lic"));

        var msoPath = args[0];
        Console.WriteLine("Extracting: {0}", msoPath);
        
        using (var stream = File.OpenRead(args[0]))
        {
            
            var dict = InlineAttachmentExtractor.EnumerateMsoPackage(stream);
            Console.WriteLine(dict.Keys);
            foreach (var k in dict.Keys)
            {
                using (var write = File.OpenWrite(string.Format("c:\\testdata\\dis-4875\\{0}.pdf", k)))
                {
                    write.Write(dict[k], 0, dict[k].Length);
                }
            }
        }

where the args[0] is filepath to the attached oledata.mso file… I was expecting to get a pdf out of it. What it returns has leading and trailing garbage around the pdf. If I remove that the pdf opens fine.

First, are we using this correctly. Currently when iterating over mapi.Attachments we get oledata.mso back instead of the pdf (in outlook it is embedded icon in the body of message). My understanding is we need to then use EnumerateMsoPackage on the mso stream to break it out.

Thanks

dis-4875.zip (1.3 MB)

see attached.

@PeteLee,

Files like “oleData.mso” refer to Microsoft Compound Document file (MCDF) format and, unfortunately, support for such files is beyond the occupation of Aspose.Email. However, libraries like OpenMCDF library for reading MCDF format in .NET once these are extracted from the message.

We have also noticed that with the latest version of the API, the API extracts PDF attachment fine from the MSG file.

Can you show me the code where you were able to get the pdf from this msg using the latest version of the api?

Using the following code with v17.12 of aspose.email I do not get the pdf… i get the following:

@@@ Capture.JPG
@@@ image001.png
@@@ image002.emz
@@@ image003.png
@@@ oledata.mso

    static void Main(string[] args)
    {
        new License().SetLicense(GetEmbeddedLicenseFile("Aspose.Total.lic"));

        var path = args[0];
        Console.WriteLine("Extracting: {0}", path);

        using (var stream = File.OpenRead(args[0]))
        {
            var mapi = MapiMessage.FromStream(stream);

            foreach (var attachment in mapi.Attachments)
            {
                Debug.WriteLine(string.Format("@@@ {0}", attachment.DisplayName));

                if (attachment.ObjectData != null && attachment.ObjectData.IsOutlookMessage)
                {
                    using (var attachmentStream = File.OpenWrite(string.Format("c:\\testdata\\dis-4875\\attach\\{0}", attachment.DisplayName)))
                    {
                        using (var ms = new MemoryStream(attachment.ObjectData.Data))
                        using (var attachedMessage = MapiMessage.FromStream(ms))
                        {
                            attachedMessage.Save(attachmentStream);
                        }
                    }
                }
                else if (attachment.BinaryData != null && attachment.BinaryData.Length > 0)
                {
                    using (var attachmentStream = File.OpenWrite(string.Format("c:\\testdata\\dis-4875\\attach\\{0}", attachment.DisplayName)))
                    {
                            attachment.Save(attachmentStream);
                    }
                }
            }
        }
    }

@PeteLee,

Could you please open the attached PDF file by clicking it from MS Outlook? When we double click it, it gives error and doesn’t open at our end. Regarding our previous statement, it seems there was some confusion for the test and the API doesn’t detect the PDF file at our end as well.