public void SendPdfReport()
{
List<MercatorSqlParam> lp = new List<MercatorSqlParam>
{
new MercatorSqlParam("@DATE_1", new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)),
new MercatorSqlParam("@DATE_2", DateTime.Today)
};
MercatorUi.Reporting.OutputDescriptorExport outputDescriptorExport = new MercatorUi.Reporting.OutputDescriptorExport(MercatorUi.Reporting.ExportReportEnum.PDF, null, MercatorUi.Reporting.ExportOpenAfterEnum.No) { ExportToBytes = true };
Api.LastError = "";
MercatorUi.Reporting.ReportingStatic.RunReportFromDocum("H2ZP118RW1", new List<MercatorUi.Reporting.OutputDescriptor> { outputDescriptorExport }, lp);
if (outputDescriptorExport.FileContent == null)
{
MercatorUi.Globals.MercatorTasksToMain.Log("Génération PDF : " + (!string.IsNullOrEmpty(Api.LastError) ? Api.LastError : "erreur inconnue"), isError: true);
}
else
{
IneoSmtp.Smtp mail = MercatorUi.Globals.MercatorTasksToMain.GetNewStmp();
mail.Subject = "Palmarès des clients";
mail.Message = "Ci-joint le palmarès de clients.";
mail.BytesAttachments = new Dictionary<string, byte[]> { { "Palmarès des clients.pdf", outputDescriptorExport.FileContent } };
if (!mail.SendMail())
MercatorUi.Globals.MercatorTasksToMain.Log("Erreur envoi mail : " + mail.Error, isError: true);
else
MercatorUi.Globals.MercatorTasksToMain.Log("Mail correctement envoyé à " + mail.Recipient);
}
}