BAQ Report Email as CSV Report Style

Create a report style option like Crystal or SSRS that is CSV Email. Allows you to generate a mixed quote comma csv and have it emailed through Print Routing. Use case, schedule the BAQ Report to print to that report style like any other scheduled print but get email with csv instead.

@josecgomez’s interim solution as BPM

string emailTo="person@company";
string emailSubject ="Daily  AP";
string emailBAQID="baq_DailyClosedAP";
 
 
System.Text.StringBuilder sb = new System.Text.StringBuilder();
 
DataTable dt = new DataTable();
 
DataSet ds = new DataSet();
ds= DatasetAdapter.ConvertToGenericDataset  (this.resultHolder.Original,"",null,true);
 
dt = ds.Tables["Results"];
if(dt.Rows.Count>0)
{
 
  IEnumerable<string> columnNames = dt.Columns.Cast<DataColumn>().
                                    Select(column => column.ColumnName);
  sb.AppendLine(string.Join(",", columnNames));
   
foreach (DataRow row in dt.Rows)
  {
      IEnumerable<string> fields = row.ItemArray.Select(field => $"{(field.GetType()==typeof(String) ? "\""+field.ToString()+"\"": field.ToString() )}");
      sb.AppendLine(string.Join(",", fields));
  }
 
  String fileName = System.IO.Path.GetTempFileName().Replace(".tmp",".csv");
   
 
  System.IO.File.WriteAllText(fileName, sb.ToString());
 
  var mailer = this.GetMailer(async: true);
  var message = new Ice.Mail.SmtpMail();
   var from =    "no-reply@company.com";
   message.SetFrom(from);
   var to =   emailTo;
   message.SetTo(to);
    
     
     message.SetSubject(emailSubject);
   var body =  "BAQ Attached";
    message.SetBody(body);
 
    Dictionary<string, string> attachments = new Dictionary<string, string>();
  attachments.Add($"{emailBAQID}.csv", fileName);
    mailer.Send(message,attachments);
}

I wonder if you just need the Electronic Compliance Module which does XML, CSV… :slight_smile:

Which seems silly to be honest.

I think you would still have to write a report then though. The idea would be you are just exporting the raw cells of the baq as a pre-defined style of some description no messing with SSRS or Crystal or any other jazz like that