C# 在客户端计算机上使用javascript获取服务器端导出的crystal报告路径,用于c中的邮件附件#

C# 在客户端计算机上使用javascript获取服务器端导出的crystal报告路径,用于c中的邮件附件#,c#,javascript,asp.net,C#,Javascript,Asp.net,下面是我打开默认outlook的javascript代码 <script language="javascript" type="text/javascript"> function SendAttach() { var theApp //Reference to Outlook.Application var theMailItem //Outlook.mailItem var attach3 = '<%= Sessi

下面是我打开默认outlook的javascript代码

<script language="javascript" type="text/javascript">
    function SendAttach() {
        var theApp //Reference to Outlook.Application 
        var theMailItem //Outlook.mailItem
        var attach3 = '<%= Session["MyFilePath"].ToString() %>'
        var recipient
        var subject = "Report Document"
        var msg = "Please Find Attached File \n\n" + "Thanks & Regards \n" + '<%=  Session["USER"].ToString() %>'
        try {
            var theApp = new ActiveXObject("Outlook.Application");
            var objNS = theApp.GetNameSpace('MAPI');
            var theMailItem = theApp.CreateItem(0) // value 0 = MailItem

            theMailItem.Subject = (subject);
            theMailItem.Body = (msg);
            theMailItem.Attachments.add(attach3);
            theMailItem.display();
        } catch (err) {
            alert("The following may have cause this error: \n" + "1. The Outlook express 2003 is not installed on the machine.\n" + "2. The msoutl.olb is not availabe at the location " + "C:\\Program Files\\Microsoft Office\\OFFICE11\\msoutl.old on client's machine " + "due to bad installation of the office 2003." + "Re-Install office2003 with default settings.\n" + "3. The Initialize and Scripts ActiveX controls not marked as safe is not set to enable.")

        }

    }
</script>

如何在客户端计算机上获取服务器端导出的文件???

您无法从客户端访问服务器端文件(除非客户端恰好与服务器在同一台计算机上运行)

您需要将文件流式传输回客户端,或将其保存在共享位置

下面是一个例子:

reportDocument = new ReportDocument();
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
reportDocument.Load(Server.MapPath("~/Boreports/Print_Lpo.rpt"));

Session["Rpt_Name"] = "Local_Purchase_Order_Rpt";
string Fname = "C://" + Session["Rpt_Name"].ToString() + ".pdf";

paramField = new ParameterField();
paramField.Name = "@LPONO";
paramDiscreteValue = new ParameterDiscreteValue();
paramDiscreteValue.Value = Session["LPO_NO"].ToString();
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
reportDocument.SetParameterValue("@LPONO", paramDiscreteValue);

paramField = new ParameterField();
paramField.Name = "@REC_TYPE";
paramDiscreteValue = new ParameterDiscreteValue();
paramDiscreteValue.Value = Session["ReportType1"].ToString();
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
reportDocument.SetParameterValue("@REC_TYPE", paramDiscreteValue);
// Session["param"] = paramFields;
//Session["reportdoc"] = "~/Boreports/Print_Lpo.rpt";
CrystalReportViewer1.ParameterFieldInfo = paramFields;
CrystalReportViewer1.ReportSource = reportDocument;
reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, Fname);
Session["MyFilePath"] = Fname;