Do not treat embedded images as attachments

I am working on a project where I am using Aspose.Email and it work perfect.
The thing is that whenever an .msg file has embedded images like “follow us + some social media icons”, Aspose will treat these icons as attachment and gives me extra pages with actually I do not need them. How can I get rid of these extra pages or make it work with only original attachment and not embedded images?

@LeotrimRamadani

Could you please ZIP and attach your .msg file along with problematic and expected output documents? We will then provide you more information about your query.

@LeotrimRamadani

We have converted the shared .msg to .pdf file format using the code example shared in the following article. We have not found the shared issue.
Saving an Email as PDF

In case you are using the old version of Aspose APIs, we suggest you please upgrade to the latest version of Aspose.Email for .NET and Aspose.Words for .NET to avoid this issue.

It’s okay now. I fixed the issue with this code. I’m leaving it here in case someone else in the future runs on the same error.

`public static bool IsInlineAttachment(MapiAttachment attachment)`
{
if (attachment.Properties[0x37140003] != null)
        {
            if (attachment.Properties[0x37140003].GetInt32() == 4)
            { 
                    if ((attachment.Properties[MapiPropertyTag.PR_ATTACH_CONTENT_ID] != null) || (attachment.Properties[MapiPropertyTag.PR_ATTACH_CONTENT_ID_W] != null))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
             }
            else
            {
                return false;
            }
        }
        else
        {
            return false;

        }
    }

And then in the main function where I convert .msg to .pdf I just call this function like:

if(IsInlineAttachment(attachment)) 
{
 continue;
}
else{
// proceed with the convertion ---
}

Thank you for your quick response, much appreciated.

@LeotrimRamadani

It is nice to hear from you that you have solved your issue. Please feel free to ask if you have any question about Aspose.Email, we will be happy to help you.

1 Like