Hello
When I try to convert the mail without Image (SkipInlineImages = True) I’ve got an exception. But the conversion works fine if SkipInlineImages = False.
Here is the code :
public static int Convert(string inputFile, string outputFile, ref string errmsg, int withImagesFromMsg)
{
errmsg = “”;
try
{
using (FileStream docStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read))
{
MemoryStream ms = new MemoryStream();
MhtSaveOptions mhtOptions = new MhtSaveOptions
{
MhtFormatOptions = MhtFormatOptions.WriteHeader | MhtFormatOptions.WriteCompleteEmailAddress,
SkipInlineImages = (withImagesFromMsg != 1) // Adjust this as needed
};var message = MailMessage.Load(docStream); message.Save(ms, mhtOptions); var loadOptions = new Aspose.Words.Loading.LoadOptions { LoadFormat = LoadFormat.Mhtml }; Document doc = new Document(ms, loadOptions); int pagecount = doc.PageCount; // Proceed with PDF conversion doc.Save(outputFile, new PdfSaveOptions()); return 0; } } catch (Exception ex) { errmsg = ex.Message + " | " + ex.StackTrace; return 1; } }
The error raise on message.Save(ms, mhtOptions);
Exception :
à System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
à System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
à #=z2uaYtStFs3lVZLiIL3faTrQylLlEEQwndQ==.#=zUTzpf7LsNcj8coAq9g==(Regex #=zC0XV0f4=, #=zWAXl_AHerTc9sH_d$aCkvcveRZzJ9MvGBGV2H44= #=zWZU1dXA=)
à Aspose.Email.MailMessage.#=zOi7IUEHJswfm(MhtSaveOptions #=zzuASPAV34t4L)
à Aspose.Email.MailMessage.Save(Stream stream, SaveOptions options)
à NovaAspose.emailUtils.Convert(String inputFile, String outputFile, String& errmsg, Int32 withImagesFromMsg)
I’m using Aspose.Email 24.12.0.0 .Net 4.8.0
COUTURIER XL - Adhésion PRO BTP.7z (2,3 Mo)