示例#1
0
        static void ExportToMSMail(string _codEmp, int _NroOrdenCompra)
        {
            StaCatalina.Forms.Reports _Reporte  = new Reports();
            ReportDocument            objReport = new ReportDocument();


            String reportPath = ConfigurationManager.AppSettings["Reports"] + "\\Reporting\\" + "OrdenDeCompra.rpt";

            objReport.Load(reportPath);
            objReport.Refresh();
            objReport.ReportOptions.EnableSaveDataWithReport = false;

            // PARAMETROS DE CONEXION
            TableLogOnInfo logoninfo = new TableLogOnInfo();

            logoninfo.ConnectionInfo.ServerName         = ConfigurationManager.AppSettings["Source"];
            logoninfo.ConnectionInfo.DatabaseName       = ConfigurationManager.AppSettings["CatalogSTACATALINA"];
            logoninfo.ConnectionInfo.UserID             = ConfigurationManager.AppSettings["User ID"];
            logoninfo.ConnectionInfo.Password           = ConfigurationManager.AppSettings["Password"];
            logoninfo.ConnectionInfo.IntegratedSecurity = false;
            Tables tables = objReport.Database.Tables;

            foreach (Table table in tables)
            {
                table.ApplyLogOnInfo(logoninfo);
            }

            //PAOS LOS PARAMTROS EN ORDEN

            objReport.SetParameterValue(0, _codEmp);
            objReport.SetParameterValue(1, "OC");
            objReport.SetParameterValue(2, _NroOrdenCompra);
            objReport.SetParameterValue(3, _NroOrdenCompra);
            objReport.SetParameterValue(4, null);
            objReport.SetParameterValue(5, null);
            objReport.SetParameterValue(6, 1);


            //PdfRtfWordFormatOptions pdfOpts = ExportOptions.CreatePdfRtfWordFormatOptions();
            PdfFormatOptions pdfOpts = new PdfFormatOptions();
            MicrosoftMailDestinationOptions mailOpts = ExportOptions.CreateMicrosoftMailDestinationOptions();
            ExportOptions exportOpts = new ExportOptions();


            pdfOpts.UsePageRange           = false;
            exportOpts.ExportFormatOptions = pdfOpts;

            mailOpts.MailCCList  = "*****@*****.**";
            mailOpts.MailMessage = "PRUEBA DE CORREO OC HECTOR";
            mailOpts.MailSubject = "PRUEBA";
            mailOpts.MailToList  = "*****@*****.**";
            mailOpts.Password    = "******";
            mailOpts.UserName    = "******";
            exportOpts.ExportDestinationOptions = mailOpts;

            exportOpts.ExportDestinationType = ExportDestinationType.MicrosoftMail;
            exportOpts.ExportFormatType      = ExportFormatType.PortableDocFormat;


            objReport.Export(exportOpts);
        }