Reporting Services 2005 Webサービスを使用してpdfを生成しようとしています。私はpdf生成部を使っていますが、途中でメールを送信する前に電子メールに添付できる「物理的な」pdfを入手する方法がわかりません。WebサービスからPDFを生成し、添付ファイルとして電子メールで送信する
私は、このガイド以下のPDFファイルを作成しました:http://www.codeproject.com/KB/reporting-services/PDFUsingSQLRepServices.aspx
public void RenderPdf(string rptMemo, string emailAddress)
{
// Prepare Render arguments
string historyID = null;
string deviceInfo = null;
string format = "PDF";
Byte[] results;
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
Rse2005.Warning[] warnings = null;
string[] streamIDs = null;
//Credentials that will be passed to reporting services
Rse2005.ReportExecutionService rsExec = new Rse2005.ReportExecutionService();
rsExec.Credentials = new NetworkCredential("username", "password", "domain");
//Report is called "Report1", it takes a parameter called "Id"
Rse2005.ExecutionInfo ei = rsExec.LoadReport("/Reports/Report1", historyID);
Rse2005.ParameterValue[] rptParameters = new Rse2005.ParameterValue[1];
rptParameters[0] = new Rse2005.ParameterValue();
rptParameters[0].Name = "Id";
rptParameters[0].Value = RptMemo;
//render the PDF
rsExec.SetExecutionParameters(rptParameters, "en-us");
results = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=DetailedQuote.pdf");
HttpContext.Current.Response.OutputStream.Write(results, 0, results.Length);
//This is very important if you want to directly download from stream instead of file.
HttpContext.Current.Response.End();
}
この時点から、私はRenderPdfメソッドを呼び出すことができると私は開く/保存/ファイルをキャンセルするよう求めています。私はハードドライブから添付ファイル付きの電子メールを送信する方法を理解していますが、結果[]をどのように処理できる形式にするかわかりません。あなたは、ディスクやメモリにPDFファイルを保存し、ここで を送信するためにSystem.Net.Mailを使用する必要があり、事前
私はSO http://stackoverflow.com/questions/919829/send-sql-report-in-e-mail-attachment-using-c-and-asp-net – adopilot