From the details it seems that you are trying to convert Email to PDF using options exposed by Aspose.Words API. You may use the following code snippet to achieve the task:
CODE:
string inputfile = "";
string outputFile = "";
MailMessage message = MailMessage.Load(inputfile);
message.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(message.Date);
MhtSaveOptions mhtSaveOptions = new MhtSaveOptions
{
MhtFormatOptions = MhtFormatOptions.WriteHeader | MhtFormatOptions.WriteCompleteEmailAddress
};
mhtSaveOptions.SkipInlineImages = false;
MemoryStream msgStream = new MemoryStream();
message.Save(msgStream, mhtSaveOptions);
msgStream.Position = 0;
var options = new Aspose.Words.LoadOptions()
{
LoadFormat = Aspose.Words.LoadFormat.Mhtml
};
var document = new Aspose.Words.Document(msgStream, options);
document.Save(outputFile, Aspose.Words.SaveFormat.Pdf);
Try it at your end update us with your feedback. In case of any issue please share sample input file and sample code along with the code to reproduce the issue.
Thank you for the help, but I have still the same problem (please see the attached document).
As I wrote in my earlier post, it works from my Console Program (PdfConverterTest.exe), but it fails when I put the code in a C# project (PdfConverter.dll) and call it from my .exe program!
My mail has only the text “Test” and nothing else.
We have tried to reproduce the said issue. We are unable to reproduce it. Sample solution along with sample input and output file is attached for your reference.
Thank for writing us back. We are using the updated versions of Aspose.Words and Aspose.Email. Screenshots of the referenced DLLs are attached. project_references.jpg (78.5 KB)
The unwanted folders and the one that can be generated were removed from the ZIP to make it lightweight. The latest versions of APIs were published in the current month. Further, we cannot share the license file with as per our policy. In case you do not have a valid license you may get one. Access the link to get a temporary license for 30 days.
Share the sample input file that is taking long time with us. Further please update us about do you want to skip/leave the images in the conversion process? In this way the images will not be present in the resultant file.
It happens often that our customers make copy/paste texts from other systems, thus images will not be copied correct, but their hashcodes will be inserted into their mails.
When we create a .PDF file, we want to keep all pictures, but skip only hashcodes!
Thank you for sharing sample. This is to update you that each of the embedded image in the message is contained in MailMessage.LinkedResource collection. If a message contains any such thing, it will be processed/read by Aspose.Email. There is no way to skip it or avoid it.