Hi,
I am converting MSG into PDF, all works well, but I would not like to have separate files for the inline images of the body of the mail, I cannot figure out what option I should use.
Using GroupDocs.Conversion.NETFramework v25.11
Hi,
I am converting MSG into PDF, all works well, but I would not like to have separate files for the inline images of the body of the mail, I cannot figure out what option I should use.
Using GroupDocs.Conversion.NETFramework v25.11
Thanks for sharing the sample. Based on your description, here is a likely technical approach for Aspose.Conversion when converting msg to pdf.
When converting a .msg file to PDF with GroupDocs.Conversion, the handling of inline images is controlled by the PDF‑specific conversion options.
If you pass a PdfConvertOptions (or the equivalent options class for the .NET Framework) you can tell the converter to embed the inline images directly into the PDF instead of extracting them as separate files, e.g.:
var converter = new Converter("message.msg");
var pdfOptions = new PdfConvertOptions
{
// set this (or a similarly named flag) to embed inline images
EmbedImages = true // <-- check the exact property name in your version
};
converter.Convert("output.pdf", pdfOptions);
Make sure you are using the options object when calling Convert; otherwise the default behavior extracts the images.
Clarifying questions
Convert are you currently using, and are you passing a PdfConvertOptions (or similar) instance to it?PdfConvertOptions class you see, is there a property that mentions embedding or extracting images (e.g., EmbedImages, ExtractImages, SaveEmbeddedImages)? If not, could you share the list of properties you have available?The inline images are correctly embedded within the mail transformed into PDF, but aside, they all become separate PDFs, that I do not want.
Hello @CyrusDaVirus ,
Thank you for contacting us.
To prevent embedded images from being created as separate PDF files, please try setting the Depth = 0 property in EmailLoadOptions, as shown in the example below.
Func<LoadContext, LoadOptions> emailOptions = loadContext => new EmailLoadOptions()
{
Depth = 0,
};
// Load the source MSG file
using (var converter = new GroupDocs.Conversion.Converter("sample.msg",emailOptions))
{
var options = new PdfConvertOptions();
converter.Convert("outputMsg.pdf", options);
}
If you have any further questions, feel free to contact us again.
When I set the depth to 0, it works, but it does not extract the attachments.
These are my current params:
var loadOptions = new EmailLoadOptions
{
ConvertOwned = true,
ConvertOwner = true,
PreserveOriginalDate = true,
ResourceLoadingTimeout = TimeSpan.FromSeconds(15),
Depth = 2
};
Hello @CyrusDaVirus ,
If your email contains attachments in addition to embedded images, unfortunately it is currently not possible to skip the conversion of embedded images as separate files using a specific property.
Our development team has registered this issue in our tracking system under the ID CONVERSIONNET-8218. As soon as it is resolved or we receive any updates, we will inform you immediately.
As a workaround, you may try preventing the image from being saved to a file by using ConvertedStreamProvider. You can find more details on how to use it in the following documentation.
If you have any further questions, please do not hesitate to contact us.