static void ExpBatchJobPrintDestinationSettingsMail(Args _args)
{
//Job data
Batch batchTable;
BatchParameters batchParameters;
container innerCon, conEmailTo, conEmailCC, conEmailSubject, conEmailBcc, conEmailReplyTo;
//For export file
TextIo exportFile;
FileName exportFileName;
int counter = 0;
#File
#define.CRLF("\r\n")
//Prepare export csv
exportFileName = @"\\yourPath\"; //File path
exportFile = new TextIo(exportFileName, #io_write);
exportFile.outFieldDelimiter(';');
exportFile.outRecordDelimiter(#CRLF);
//Write header
exportFile.write("emailSubject;emailTo;emailCC;emailBcc;emailReplyTo");
//Job
while select batchTable where batchTable.Caption LIKE "D*" //Query as you need
{
counter++;
//Reset containers, just to make sure we dont export data from the last record
batchParameters = conNull();
innerCon = conNull();
conEmailTo = conNull();
conEmailCC = conNull();
conEmailSubject = conNull();
conEmailBcc = conNull();
conEmailReplyTo = conNull();
//Iterate batchParameters containers. NOTE: the 2nd parameters (integers) 'where to peek' may differ, depending on custom fields
batchParameters=batchTable.Parameters;
innerCon = conPeek(batchParameters, 5);
innerCon = conPeek(innerCon, 7);
innerCon = conPeek(innerCon, 2);
innerCon = conPeek(innerCon, 2); //DataContractMap
innerCon = conPeek(innerCon, 6); //SRSPrintDestinationSettings
conEmailTo = conPeek(innerCon, 7);
conEmailCC = conPeek(innerCon, 5);
conEmailSubject = conPeek(innerCon, 6);
conEmailBcc = conPeek(innerCon, 12); //Custom field
conEmailReplyTo = conPeek(innerCon, 13); //Custom field
exportFile.write(strFmt("%1;%2;%3;%4;%5",
conPeek(conEmailSubject, 2),
conPeek(conEmailTo, 2),
conPeek(conEmailCC, 2),
conPeek(conEmailBcc, 2),
conPeek(conEmailReplyTo, 2)));
}
info(strFmt("Exported %1 records", counter));
}
André Arnaud de Cal...
294,261
Super User 2025 Season 1
Martin Dráb
233,004
Most Valuable Professional
nmaenpaa
101,158
Moderator