Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the "send page by email" feature in Internet Explorer choose to send as the body of an email, or as an attachment?

Tags:

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
like image 382
Rowland Shaw Avatar asked Jun 07 '11 14:06

Rowland Shaw


People also ask

How do I email a page from Internet Explorer?

To use this Internet Explorer function go to the web page you want to email, then click on File in the Menu Bar at the top of the Internet Explorer screen, then click on “Send” from the drop down list, and then select “Page by Email” or “Link by Email” from the new list that appears.

How do I send a link in Microsoft edge?

However, you can use Internet Explorer if you wish to and if you want to send a page or a link to someone via e-mail from Edge, go to top right corner of the browser, you'll find a share option, just click on that and send the webpage to the desired email address. You can also copy paste the URL as usual.


1 Answers

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");
like image 85
oleschri Avatar answered Oct 01 '22 12:10

oleschri