2016-02-09 76 views
0

我想发送一份电子邮件作为pdf的附件,而不保存/导出在telerik报告查看器的某个地方,但我找不到方法。发送电子邮件从telerik报告查看器

另外,当我在调试模式和查看设计师我看到这个按钮,并在属性没有任何电子邮件。

enter image description here

当我运行此按钮不会显示在浏览器的项目。 任何人都知道为什么?

我试着用这段代码制作一个按钮,但我无法将报告从我的代码转换为pdf。

protected void RadButton1_Click(object sender, EventArgs e) 
     { 
      string type = Request.Params["type"]; 
      string no = Request.Params["no"]; 
      string stat = Request.Params["stat"]; 

      //Session["compcode"] = Request.Params["compcode"]; 

      var instanceReportSource = new Telerik.Reporting.InstanceReportSource(); 
      instanceReportSource.ReportDocument = new Reports.Report1(); 
      instanceReportSource.Parameters.Add("docno", no); 
      instanceReportSource.Parameters.Add("doctype", type); 
      instanceReportSource.Parameters.Add("docstat", stat); 

      try 
      { 
       // Create the Outlook application. 
       Outlook.Application oApp = new Outlook.Application(); 
       // Create a new mail item. 
       Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem); 
       // Set HTMLBody. 
       //add the body of the email 
       oMsg.HTMLBody = "Hello, Jawed your message body will go here!!"; 
       //Add an attachment. 
       String sDisplayName = "MyAttachment"; 
       int iPosition = (int)oMsg.Body.Length + 1; 
       int iAttachType = (int)Outlook.OlAttachmentType.olByValue; 
       //now attached the file 
       Outlook.Attachment oAttach = oMsg.Attachments.Add("here must be the report as pdf", iAttachType, iPosition, sDisplayName); 
       //Subject line 
       oMsg.Subject = "Your Subject will go here."; 
       // Add a recipient. 
       Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients; 
       // Change the recipient in the next line if necessary. 
       Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("[email protected]"); 
       oRecip.Resolve(); 
       // Send. 
       oMsg.Send(); 
       // Clean up. 
       oRecip = null; 
       oRecips = null; 
       oMsg = null; 
       oApp = null; 
      }//end of try block 
      catch (Exception ex) 
      { 
       string ep = ex.ToString(); 
      }//end of catch 


     } 

回答

0

您在上面画圈的按钮是显示/隐藏报告查看器的参数区域。如果您查看报表查看器的文档,它将解释如何自定义工具栏,这将允许您将电子邮件按钮添加到工具栏上。然后在你的代码中,你必须以某种格式(可能是pdf)将报告呈现为内存流,然后将其附加到您的电子邮件引擎。他们有一个如何通过电子邮件发送报告的旧例子:http://www.telerik.com/blogs/send-telerik-report-as-email-attachment

+0

这并不能帮助我,不清楚如何创建自定义工具栏。 – marios

+0

您可以通过覆盖ReportViewer TargetType的样式来创建自定义工具栏。我建议您在Telerik博客上搜索您正在使用的ReportViewer版本的示例。 – Bradley

相关问题