When saving an email as pdf file, it does not show sender’s email address in the pdf file.
Could someone help me?
I’m using the below code:
mailMessage = MailMessage.Load(emailMSG, msgLoadOptions);
string sender = mailMessage.From.User ?? “”;
string fileName = string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}_" + sender, mailMessage.Date);
if (!Directory.Exists(outputDir))
Directory.CreateDirectory(outputDir);
var wordLoadOptions = new Aspose.Words.LoadOptions()
{
LoadFormat = Aspose.Words.LoadFormat.Mhtml
};
mhtSaveOptions.SkipInlineImages = false;
using (var mhtStream = new MemoryStream())
{
mailMessage.Save(mhtStream, mhtSaveOptions);
Aspose.Words.Document doc = new Aspose.Words.Document(mhtStream, wordLoadOptions);
doc.Save(outpuFrom address not displayed.JPG (6.5 KB)
tDir + “\” + fileName + “.pdf”, Aspose.Words.SaveFormat.Pdf);
}
@Senth,
Thank you for your request. Could you share the email file you are loaded in the code example, please? Also, please share a comleted code snippet (msgLoadOptions
and mhtSaveOptions
variables are unknown).
@Andrey_Potapov,
I’ve uploaded sample email files(MSG) and full source code. Please refer method SaveEmailAsPDF in the file. To Aspose.zip (219.5 KB)
@Senth,
To display email addresses in MHTML/PDF files, you should enable appropriate options as below:
var mhtSaveOptions = MhtSaveOptions.DefaultMhtml;
mhtSaveOptions.MhtFormatOptions = MhtFormatOptions.WriteHeader | MhtFormatOptions.WriteCompleteEmailAddress;
More details: Converting to MHTML with Optional Settings
API Reference: MhtFormatOptions Enumeration