【问题标题】:how to embed ssrs report in outlook?如何在outlook中嵌入ssrs报告?
【发布时间】:2015-08-20 05:23:42
【问题描述】:

在我们的组织中,我们从 SSRS 报告中导出 excel 文件,并将该 excel 文件附加到 Outlook 中。我们还从 excel 文件表中复制选定的部分并粘贴到 Outlook 邮件正文中。

如果我们在SSRS服务器中安排报告并选择MHTML选项发送邮件,那么所有的excel表格内容都包含在outlook邮件正文中并自动发送邮件。

我希望邮件正文中仅包含 ssrs 报告的指定部分(就像我们手动复制和粘贴一样)并自动发送邮件。

感谢您的帮助。

谢谢:-)

【问题讨论】:

  • 您可以编辑 SSRS 报告吗?您是否正在尝试整合数据?这个剪切和粘贴过程是否需要在某处填充数据库?
  • 所以你想要一个 mhtml 的部分和同一个订阅电子邮件中的一个 excel 附件?
  • @Nick.McDermaid 是的,我可以编辑 SSRS 报告。我只希望 SSRS 报告的唯一指定 tablix 出现在 Outlook 的电子邮件正文中。
  • @BhupeshC 是的,我希望只有 SSRS 报告的特定 tablix 出现在 Outlook 的电子邮件正文中。例如。我有 TablixA 和 TablixB。我只希望 TablixA 出现在电子邮件正文中,而不是整个 SSRS 报告中。
  • 如果您可以编辑报告,那么我建议您在报告中添加一个参数,允许您有条件地隐藏或显示 Tablix B。当您通过电子邮件运行报告时,您将此参数设置为隐藏 Tablix B . 您可能希望默认参数以显示 Tablix B,这样现有的使用不会受到影响。 SSRS 输出在呈现后很难处理。

标签: email reporting-services outlook ssrs-2008-r2


【解决方案1】:
  string reportName = Your Report Name;



        Warning[] warnings;
        string[] streamIds;
        string encoding = string.Empty;
        string extension = string.Empty;
        string mimeType = string.Empty;
        // Setup the report viewer object and get the array of bytes

        var rptViewer = new ReportViewer();
        string urlReportServer = ReportServer Path;
        rptViewer.ProcessingMode = ProcessingMode.Remote; // ProcessingMode will be Either Remote or Local
        rptViewer.ServerReport.ReportServerUrl = new Uri(urlReportServer); //Set the ReportServer Url
        string folderName = FolderName;
        rptViewer.ServerReport.ReportPath = folderName + reportName; //Passing the Report Path                

        //Creating an ArrayList for combine the Parameters which will be passed into SSRS Report
        var reportParam = param1;

        ReportParameter[] param = new ReportParameter[reportParam.Count];
        for (int k = 0; k < reportParam.Count; k++)
        {
            param[k] = (ReportParameter)reportParam[k];
        }
        // pass crendentitilas
        string userName, password, domain;
        userName = SSRSUserName;
        password = SSRS Password;
        domain = SSRS User Domain;
        IReportServerCredentials irsc = new BLL.Reports.CustomReportCredentials(userName, password, domain);
        rptViewer.ServerReport.ReportServerCredentials = irsc;

        //pass parmeters to report
        rptViewer.ServerReport.SetParameters(param); //Set Report Parameters
        rptViewer.ServerReport.Refresh();

        byte[] bytes = rptViewer.ServerReport.Render("HTML4.0", null, out mimeType, out encoding, out extension,
            out streamIds, out warnings);
        string reportasHTML= Encoding.ASCII.GetString(bytes);
                    var smtp = new SmtpClient
                    {
                        Host = "smtp.gmail.com",
                        Port = 587,
                        EnableSsl = true,
                        DeliveryMethod = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Credentials = new NetworkCredential(SenderID, SenderPassword)
                    };
                    using (var message = new MailMessage(Email ID, Email ID)
                    {
                        Subject = "test",
                        Body = reportasHTML,
                        IsBodyHtml =true

                    })
                    {
                        smtp.Send(message);
                    }

【讨论】:

  • 欢迎来到 Stack Overflow!不鼓励仅使用代码的答案。请单击编辑并添加一两段来总结您的代码如何解决问题。谢谢。
猜你喜欢
  • 1970-01-01
  • 2021-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多