我想发送一封电子邮件作为pdf附件,而不是从telerik报告查看器中保存/导出它,但我找不到办法。
此外,当我处于调试模式并查看设计器时,我看到此按钮,并且属性上没有任何电子邮件内容。
当我在浏览器上运行项目时,此按钮无法显示。 谁知道为什么?
我尝试使用此代码创建一个按钮,但我无法从代码中将报告转换为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("xxxxx@gmail.com");
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 :(得分:0)
您在上方圈出的按钮是显示/隐藏报告查看器的参数区域。如果您查看报告查看器的文档,它将解释如何自定义工具栏,这将允许您在工具栏上添加电子邮件按钮。然后在您的代码中,您必须以某种格式(可能是pdf)将报告呈现到内存流中,然后将其附加到您的电子邮件引擎。他们有一个关于如何通过电子邮件发送报告的旧示例:http://www.telerik.com/blogs/send-telerik-report-as-email-attachment。