Hi
I'm running two reports in a job queue (NAV 2016)
The first report post all sales orders that have been delivered the same day. This works fine - everything is posted.
Then I have a simple report that sends the invoices to the customer on email (as PDF). This report works fine, when I run the report manually (just pressing OK on the report), but when it is run in the Job queue nothing happens - exept that it is registred as run successfully in the job queue log entry.
Does anyone have any suggestions on why this happens...
Code to send report as PDF
//>>OnRun
CLEAR(SalesInvoiceHeader);
SalesInvoiceHeader.SETFILTER("No.",'141721'); //Only one invoice - for testing
IF SalesInvoiceHeader.FINDSET THEN REPEAT
RecRef.GETTABLE(SalesInvoiceHeader);
ReportID := EmailMgt.GetReportIDFromRecRef(RecRef);
IF ReportID = 0 THEN
ERROR('No report');
EmailMgt.SendReport(ReportID,RecRef,SalesInvoiceHeader."Bill-to E-mail",TRUE);
MailCount += 1;
UNTIL SalesInvoiceHeader.NEXT = 0;
//EmailMgt.SendReport
ErrorMessage := '';
IF ReportID = 0 THEN
ErrorMessage := Text012;
IF ErrorMessage = '' THEN
ErrorMessage := SetupEmailTemplate(RecRef,RecipientEmail,Silent,EmailTemplateHeader);
IF EmailTemplateHeader."Default Recipient Address" = '' THEN
EXIT;
IF ErrorMessage = '' THEN
ErrorMessage := CreateSmtpMessageFromEmailTemplate(EmailTemplateHeader,RecRef,ReportID);
AddEmailAttachmentsToSmtpMessage(EmailTemplateHeader);
IF ErrorMessage = '' THEN BEGIN
Filepath := GetFilepath();
Filename := GetFilename(EmailTemplateHeader,RecRef);
RecRef.SETRECFILTER;
IF NOT PrintPDF(ReportID,RecRef,Filepath,Filename) THEN
ErrorMessage := STRSUBSTNO(Text006,ReportID);
END;
IF ErrorMessage = '' THEN BEGIN
IF NOT AddFileToSmtpMessage(Filepath + Filename) THEN
ErrorMessage := Text009;
IF ERASE(Filepath + Filename) THEN;
END;
IF ErrorMessage = '' THEN
ErrorMessage := AddAdditionalReportsToSmtpMessage(EmailTemplateHeader,RecRef,Filepath);
IF ErrorMessage = '' THEN
ErrorMessage := SendSmtpMessage(RecRef,Silent);
FileManagement.DeleteServerFile (Filepath + Filename);
IF (ErrorMessage <> '') AND NOT Silent THEN
ERROR(ErrorMessage);
EXIT(ErrorMessage);
0
Comments
what is variable EmailMgt?
check SendReport parameters.
may be last one is related to it?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
I removed the Request page, but that didn't do it.
The EmailMgt is a codeunit the handles the SMTPsending of an email.
I also tried to copy the code to a codeunit instead of a report, but it doesn't help either
how di you remove requestpage?
I mean to say handle the OK button of request page
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
I have skipped the report and run the functions in a codeunit. Again - it works when i press the button, but not when I run it through Job Queue.
Could it be something with the handling of the pdf-file to be attached?
It works from the client - but not from server...