Shrink SSRS HTML5 rendered document size for gmail

I have a C# app that generates SSRS Reports which are either attached to an email or added to the body of the message if the rendering format is HTML. Emails are looking great and then someone opens it in the gmail web client and sees a nasty [message clipped] message, turn outs gmail clips the contents of an email body if it is bigger than 105kb.

After reviewing some documentation,, I noticed that the rendering engine will render both a full HTML and fragmented HTML document. Wouldn’t you know it the fragmented version is much smaller, all styling is inline and not so bloated with javascript.

I render my reports using the ReportExecutionService class which contains a method called Render; Render accepts a DeviceInfo parameter that when set to null gives you the full HTML document, however if you set the value of DeviceInfo to   @"<DeviceInfo><StreamRoot>/</StreamRoot><HTMLFragment>True</HTMLFragment></DeviceInfo>" you get a fragmented small html file that renders in gmail perfectly.

The code snippet below provides a simple inline if statement to set the value

string deviceInfo = format == "HTML5" ? @"<DeviceInfo><StreamRoot>/</StreamRoot><HTMLFragment>True</HTMLFragment></DeviceInfo>" : null; 


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s