“通过电子邮件发送页面”是如何实现的? Internet Explorer 中的功能选择作为电子邮件正文还是作为附件发送?
当对应用程序中包含 Crystal Reports ASP.Net 查看器的页面使用 Internet Explorer 中的“通过电子邮件发送页面”功能时,它会在 Outlook 中起草电子邮件,并将网页作为附件,而不是作为电子邮件正文。
对于以前版本的框架 (v1.1) 和关联的 Crystal 报表查看器,情况并非如此。鉴于现在不支持这些旧版本,我想知道是否有任何方法可以“鼓励”Internet Explorer 的“通过电子邮件发送页面”功能将我的 ASP.Net 页面作为正文而不是附件发送?
作为参考,查看器的源代码很简单:
<%@ 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"> </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>
在后面的代码中,我们只需:
Dim rpt As New MyReport()
rpt.SetDataSource(ds)
CrystalReportViewer.ReportSource = rpt
CrystalReportViewer.Visible = True
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"> </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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能不是您问题的直接答案,但是
我建议您的解决方案不要过于依赖浏览器功能,您的首选浏览器的未来版本可能不支持或以不同方式支持该功能。
如果您的 Web 应用程序支持每个特定报表呈现的永久 URL 之类的功能,一封带有 URL 作为链接的电子邮件就足够了。
另一种选择是将您的报告呈现为 PDF(或 XLS)以获得可安全附加到您的电子邮件的快照。
还有一种选择是不依赖于客户端浏览器的电子邮件功能,而是由 Web 应用程序本身通过 SMTP 服务器发送电子邮件。
以下是如何在 VB 中发送带有附件的电子邮件的示例.NET
如果您无法选择上述所有内容,在某些情况下,我成功地让 IE 改变了其猜测如何处理页面内容的行为:发送额外的 http 标头(如 http://www.ietf.org/rfc/rfc2183 中定义。 txt)
content-disposition: inline
与content-disposition:attachment
在最终报告呈现之前放置的示例 (C#)
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
versuscontent-disposition: attachment
Example (C#) to put before final report rendering
它由协议(文件或 HTTP)和网页内容决定。
http://support.microsoft.com/kb/304694
It's determined by the protocal (file or HTTP) and the content of the web page.
http://support.microsoft.com/kb/304694