【发布时间】:2016-02-09 08:18:50
【问题描述】:
我想以 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
}
【问题讨论】:
标签: c# asp.net telerik email-attachments telerik-reporting