20

When using the "Send page by email" feature in Internet Explorer for pages within our application that include a Crystal Reports ASP.Net viewer, it drafts the email in Outlook with the web page as an attachment, rather than as the body of the email.

With a previous version of the framework (v1.1), and associated Crystal report viewer, this was not the case. Given those older versions are now unsupported, I'd like to know if there is any way I can "encourage" the "Send page by email" feature of Internet Explorer to send my ASP.Net page as the body instead of as an attachment?

For reference, the source for the viewer is simply:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="GeneralReport.aspx.vb" Inherits="MyApplication.GeneralReportForm"%>
<%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD>
        <title></title>
        <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
        <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
        <meta content="JavaScript" name="vs_defaultClientScript">
        <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
        <LINK href="Styles.css" type="text/css" rel="stylesheet">
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <div id="contentstart">&nbsp;</div>
            <DIV><CR:CRYSTALREPORTVIEWER id="CrystalReportViewer" runat="server" DisplayToolbar="False" SeparatePages="False"
                    HasDrillUpButton="False" EnableDrillDown="False" DisplayGroupTree="False" HasSearchButton="False" HasZoomFactorList="False"
                    HasGotoPageButton="False" Visible="False" Height="50px" Width="350px"></CR:CRYSTALREPORTVIEWER>
            </DIV>
            <br>
            <asp:label id="lblError" runat="server" Width="743px" Font-Size="Larger" ForeColor="Red"></asp:label>
        </form>
    </body>
</HTML>

In the code behind, we simply have:

Dim rpt As New MyReport()
rpt.SetDataSource(ds)
CrystalReportViewer.ReportSource = rpt
CrystalReportViewer.Visible = True
Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • Could you post (part of) the HTML resulting from both the old and the new call? Or better yet, a HTTP log (fiddler) with full headers? We might be able to spot the significant difference, opening the path to possible solutions. For example, a known cause is text/comments before the open tag. – Paul-Jan Jun 16 '11 at 10:01
  • The call stayed the same. Unfortunately this has only been spotted following an upgrade; Ultimately, I'm more interested in what influences the decision, and how that decision can be influenced. – Rowland Shaw Jun 16 '11 at 12:42
  • The theory is that the outputted HTML and/or HTTP headers force that decision. By old and new, I was referring to 'output from the call under the old framework' and 'output from the call under the new framework'. – Paul-Jan Jun 16 '11 at 13:50

2 Answers2

2

This may not be a direct answer to your question, but I suggest making your solution not too dependent on a browser feature that may not be or be differently supported in future versions of your preferred browser.

If your web application supports something like a permanent URL for each specific report rendering, an email with the URL as a link should be enough.

Another option would be to render your report as PDF (or XLS) to get a snapshot that can be safely attached to your email.

Still another option is to not depend on the client's browser an email abilities but to send emails by the web application itself through an SMTP server.

Here is an example of how to send an email with an attachment in VB.NET

In case all of the above is not an option to you, in some cases I had success budging IE to change its guess-how-to-handle-page-content behavior by sending an additional http header (as defined in http://www.ietf.org/rfc/rfc2183.txt)

content-disposition: inline versus content-disposition: attachment

Example (C#) to put before final report rendering

HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = "text/html";
HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename=report.htm");
oleschri
  • 2,012
  • 11
  • 21
  • The recipient of the email cannot see the (internal) web application, so a link is out; The recipient of the email is reporting that he cannot read attachments, which is why I want to stop IE from attaching the webpage as a .htm file, but instead inline it as the actual email (like it does for so many webpages) – Rowland Shaw Jun 21 '11 at 13:25
  • @Rowland - And you cannot create the email inside your web application? You then had total control over the generated HTML-email. I understand this might be a totally new feature of the application. – oleschri Jun 21 '11 at 20:57
  • @Rowland - Just found a comment that mentions, if Outlook is configured to send mails in plain text by default - of course - IE has to send web pages as attachment, same goes for having Word set as email editor – oleschri Jun 21 '11 at 21:01
  • 2
    upvoted for poor SO etiquette on the downvotoers' part. why is this not a good answer? – Jeff Oct 05 '11 at 18:51
  • @Jeff at no point does the answer address the actual question of how Internet Explorer/Outlook chooses whether to attach as a HTML file, or inline the content. – Rowland Shaw Feb 19 '12 at 18:26
  • 2
    @RowlandShaw do I understand correctly that, if you ask someone if there is a better orange to drive a nail into a wall, and someone suggests using a hammer, it is bad advice because it is not a kind of orange? \*g\* – oleschri Feb 20 '12 at 09:25
  • @oleschri Well, in our situation, the best option was to throw the Crystal Report viewer away altogether and just generate the HTML ourselves, as "something" the newer version did was causing the change in behaviour. Still no wiser as to what the "something" is, which was what the question actually was to find out... – Rowland Shaw Feb 20 '12 at 13:56
  • @oleschri As for the oranges, if the customer chooses to send the page via email, who are we to disagree? I couldn't justify the development hours in this case to try and implement a feature that the browser already has... – Rowland Shaw Feb 20 '12 at 13:59
  • @RowlandShaw So in the end you had to take a different route anyway :) But I can feel your pain about telling the customer he should pay for developing a feature that has worked fine until then. – oleschri Feb 20 '12 at 16:09
0

It's determined by the protocal (file or HTTP) and the content of the web page.

Web pages that you access by using the "file://" protocol (for example, files on your local computer or local area network) are sent as attachments with an .htm extension. Web pages that you access by using the "http://" protocol are sent as attachments with a .txt extension if the HTML file contains a large comment before the tag.

http://support.microsoft.com/kb/304694

Jim
  • 1,695
  • 2
  • 23
  • 42
  • In my case, they are not using the file:// protocol nor is there any comment in the webpage prior to the opening `` tag (they are being attached as .htm files, which indicates that condition is not being hit) – Rowland Shaw Jun 16 '11 at 12:50
  • If you didn't explain the exact case of your question, you really shouldn't expect people to answer the exact case of the problem you're facing. If the down vote comes from you or for that reason, the *shrugs. – Jim Feb 20 '12 at 05:04
  • Well, the question does include the source for the ASP.Net page that I was interested in, although if there was an answer that covered the generic case, that'd be useful for others as well. Of course, I cannot talk for all those that voted for your answer. – Rowland Shaw Feb 20 '12 at 13:53