Example #1
0
        public void ExportReport(ReportDocument report)
        {
            ExportOptions options = new ExportOptions();

            options.ExportDestinationType = (ExportDestinationType)_destinationType;
            options.ExportFormatType      = (ExportFormatType)_destinationFormat;

            if (_destinationType == ReportDestination.Disk)
            {
                DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions();
                diskOptions.DiskFileName = _destinationFileName;

                options.ExportDestinationOptions = diskOptions;
            }
            else if (_destinationType == ReportDestination.Disk)
            {
                MicrosoftMailDestinationOptions mailOptions = new MicrosoftMailDestinationOptions();
                mailOptions.MailSubject = _mailSubject;
                mailOptions.MailMessage = _mailMessage;
                mailOptions.MailToList  = _mailToList;
                mailOptions.MailCCList  = _mailCCList;

                options.ExportDestinationOptions = mailOptions;
            }

            report.Export(options);
        }
Example #2
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);
        }