I'm using the SSRS web service to generate HTML4.0 format reports and then I'm trying to send them with System.Net.Mail (I know SSRS has built in report scheduling, but we have a requirement to handle all scheduled processes in a central location). So, I'm generating the html files and then trying to construct the mail message something like this :
using (var sw = new StreamReader(htmlFile))
{
mail_body = sw.ReadToEnd();
}
var mail = new MailMessage
{
From = new MailAddress(mail_from),
Subject = mail_subject,
IsBodyHtml = true,
Body = mail_body
};
The only problem being that when I do this, although the html file looks fine when I open it in a browser, in Outlook it ends up horizontally squashed.
e.g. this is what my html file looks like in IE :
But after when I send the email using the method above, in Outlook it ends up looking like this :
It seems as though there's some kind of line width limit being imposed, but I'm not sure at what level this is happening.
Does anyone have any insight at all as to what might be causing this?
Thanks!
We faced a similar problem and after a lot of workarounds we finally found out the one parameter in SSRS configuration that did the trick: OutlookCompat. With this enabled the HTML4.0 e-mails no longer look squished in Outlook.
See the MSDN documentation for more details. You can set this value either in the SSRS configuration file (for all reports and callers) or directly when calling the ASMX.
Example of the SSRS configuration:
<Extension Name="HTML4.0" Type="...">
<Configuration>
<DeviceInfo>
<OutlookCompat>True</OutlookCompat>
</DeviceInfo>
</Configuration>
</Extension>