I had this method working whereby I am sending a specific report as a PDF attachment to an email I am sending. However, I had a request from our user that asked for Excel version instead. So I thought it's no biggy. Rather that sending 'SAVEASPDF', I just changed it to 'SAVEASEXCEL'. Note that prior to sending the report as pdf/excel, I am filtering the source data (need to filter the document date). I do this using recordref and fieldref. Like I said, everything worked when sending report as PDF. See below code snippet:
OpenOrderRangeFile := TempFilename + 'OrderingReport_'+FORMAT(StartDate,0,'<Month,2>_<Day,2>_<Year4>')+'_'+FORMAT(EndDate,0,'<Month,2>_<Day,2>_<Year4>')+'.xls' ;
FieldRefVar := RecRef.FIELD(99); //Document Date
FieldRefVar.SETRANGE(StartDate,EndDate);
IF RecRef.COUNT > 0 THEN
BEGIN
bAttached := TRUE;
VarRecRef := RecRef;
//REPORT.SAVEASPDF(50097,OpenOrderRangeFile,VarRecRef);
REPORT.SAVEASEXCEL(50097,OpenOrderTodayFile,VarRecRef); //save as excel
MailInt.AddAttachment(OpenOrderRangeFile); //for attachment
END
ELSE
Now, when I changed to SAVEASEXCEL, I get below err message:
Attachment c:\temp\OrderingReport_10_01_2014_10_14_2014.xls does not exist or can not be accessed from the program.
This is because the Excel file was not created.
Thoughts anyone?
*This post is locked for comments