Editing HTML with C#
I have written an application that takes some HTML files exported by SSRS and sets them as the Body of an Email. However, the reports for some reason are being rendered too narrow. When I open the HTML file in a browser they appear correctly.
I was wondering what the best way to increase the width of the tables in the Email. I was thinking of parsing through the html file and adding a style tag like
<style>
table.x_MsoNormalTable {
width: 1000px;
}
</style>
to the top of the file .开发者_C百科.. however I'm having trouble figuring out how to edit the html in the file, or if this solution would even work. Or if I would need to do something to the actual email body property in order to increase the width of the report.
Not sure if there's a better way to solve this specific problem, but for editing the HTML in C# your best bet is probably the HTML Agility Pack.
The problem is that CSS and E-Mail clients don't mix very well. See here for more info, including explanations and workarounds.
Just wanted to say thanks for the suggestions. In the end I opted to render the SSRS reports as TIFF file exports, and then did some research on embedding images within mail messages using Linked Resources (sending mail along with embedded image using asp.net)
I believe there is also a way to use linked resources for an entire html file as well, which too may have been a viable solution. But I was really researching a quick and easy way to make this happen.
Thanks again for the input
精彩评论