Hello!
Assume we have the following sample HTML body to be sent with Aspose.Email:
<html>
<head>
<style>
<!--HTML comment-->
body {
background-color: lightblue;
}
</style>
</head>
<body>
Hello World!
</body>
</html>
When saving the sent mail to file, using the following save format SaveOptions.CreateSaveOptions(MailMessageSaveType.OutlookMessageFormatUnicode), opening the created file shows incorrect result - the CSS style is visible as text. Check the result here. (34.3 KB)
However, opening the originally sent mail from inbox using Outlook 2016, the received mail does not seem to be affected by this - the CSS is not being shown as a text.
Here is a sample code which I used to send the mail:
string fromAddress = "from@domain.com";
string toAddress = "to@domain.com";
string subject = "Sample subject";
string host = "host.domain.com";
License license = new License();
license.SetLicense("Aspose.Total.lic");
using (MailMessage message = new MailMessage())
{
message.Subject = subject;
message.From = fromAddress;
message.To.Add(toAddress);
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
message.HtmlBody = File.ReadAllText("mail.html");
using (SmtpClient smtpClient = new SmtpClient())
{
smtpClient.Host = host;
smtpClient.Port = 25;
smtpClient.Timeout = 300000;
smtpClient.Send(message);
string fileName = string.Format("GeneratedMessage_{0}.msg", DateTime.Now.ToString("yyyyMMddHHmmss"));
MsgSaveOptions saveOptions = (MsgSaveOptions)SaveOptions.CreateSaveOptions(MailMessageSaveType.OutlookMessageFormatUnicode);
message.Save(fileName, saveOptions);
}
}
Please provide us a solution for this.
Thank you.