I have a report than i want to send by e-mail after convert it in pdf file. I have the following code in onPostReport
IF GeneradoAutomatico THEN BEGIN
CLEAR (PDFCreatorOption);
FileDirectory := Text024;
FileName := Text025 + FORMAT(FechaRecuento) + '.pdf';
IF ISCLEAR(PDFCreator) THEN
CREATE(PDFCreator);
IF ISCLEAR(PDFCreatorError) THEN
CREATE(PDFCreatorError);
PDFCreatorError := PDFCreator.cError;
IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN
ERROR('Status: Error: ' + PDFCreatorError.Description);
IF ISCLEAR(PDFCreatorOption) THEN
CREATE(PDFCreatorOption);
PDFCreatorOption := PDFCreator.cOptions;
PDFCreatorOption.UseAutosave := 1;
PDFCreatorOption.UseAutosaveDirectory := 1;
PDFCreatorOption.AutosaveDirectory := FileDirectory;
PDFCreatorOption.AutosaveFormat := 0;
PDFCreatorOption.AutosaveFilename := FileName;
PDFCreator.cOptions := PDFCreatorOption;
PDFCreator.cClearCache;
DefaultPrinter := PDFCreator.cDefaultPrinter;
PDFCreator.cDefaultPrinter := 'PDFCreator';
PDFCreator.cPrinterStop := FALSE;
Espera := 0;
REPEAT
Espera += 1;
UNTIL PDFfile.OPEN(FileDirectory + '\' + CONVERTSTR(FileName,'/','_'));
FicheroExistVinos := FileDirectory + '\' + CONVERTSTR(FileName,'/','_');
mail.NewMessage(DirEMailTo,DirEMailCC,Asunto, '',FicheroExistVinos,FALSE);
END;
The pdf file isn't attachmented to the e-mail because isn't generated. Could somebody say me which can be the problem?
Thanks a lot!
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Espera := 0;
PDFfile.WRITEMODE := TRUE;
REPEAT
Espera += 1;
UNTIL PDFfile.OPEN(FileDirectory + '\' + CONVERTSTR(FileName,'/','_'));
PDFfile.CLOSE;
and don't exit. I run the report from the job scheduler, could be this the problem?
1) add condition to end when the Espera is greater than some max (and add some delay into the loop to not overstress the CPU - e.g. SLEEP(500)
2) If it never end it means that the file was not created or was created under different name or folder. Check if the PDF was created, if the name is correct and if the folder is correct...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
SetSnoozeTime resets integer variable to 3000, while IncrSnoozeTime increments the integer value by 1000.
And this is the function PrintPDF;
I would welcome comments on my code, so that I might improve it. As I said it works fine and all the pdf attachments are generated, but it might not be the most time efficient way of doing things...
The last thing I did was to modify the codeunit Mail, so that it could send multiple attachments;
Try using
REPEAT
UNTIL PDFCreator.cIsConverted;
Instead of this
I found this function in PDFCreator Version 0.9.5