We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

CSS style displayed as text when saving mail to MSG

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.

@careall,

We were able to observe the problem at our end but no other alternative could be found as a solution to this. It has been logged as EMAILNET-38836 for further consideration by our Product team. We’ll update you here once there is further information available in this regard.

@careall,

This issue has been fixed in the latest release of Aspose.Email for .NET 17.10 which is available for download now.