Problem with Bullzip and automated mail

BluefingerBluefinger Member Posts: 20
Hi,

I have a problem with creating a PDF using Bullzip followed by an automated Mail. Although I run the report modally, the PDF is not ready when I create the email. If I do it in debug mode, then it works. Here's the code I am using:
SetupIE.GET(SetupIE.Direction::Export,'REM',0);
PDFFileName := SetupIE."Path 1" + "No." + '.pdf';
CLEAR(ReminderReport);
PrintRec := Rec;
PrintRec.SETRECFILTER;
ReminderReport.SETTABLEVIEW(PrintRec);
IF EXISTS(PDFFileName) THEN
  ERASE(PDFFileName);

IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);

BullZipPDF.Init;
BullZipPDF.LoadSettings;
BullZipPDF.SetValue('Output',PDFFileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);

ReminderReport.USEREQUESTFORM := FALSE;
ReminderReport.RUNMODAL;

Mail.NewMessage('dunkel@hertz.at','','Mahnung ' + FORMAT("No."),'',PDFFileName,TRUE);

any ideas?

Comments

  • KYDutchieKYDutchie Member Posts: 345
    You should give it sometime to create the file. It might take a couple of seconds. I usually do:

    ReminderReport.USEREQUESTFORM := FALSE;
    ReminderReport.RUNMODAL;
    
    CLEAR(waitloop); // just another integer
    WHILE ((NOT EXISTS(PDFFileName)) AND (waitloop < 10)) DO BEGIN
        Waitloop += 1;
        sleep(1000);
    END;
    
    IF Waitloop => 10 then 
      error('File %1 not found', PDFFileName);
    
    Mail.NewMessage('dunkel@hertz.at','','Mahnung ' + FORMAT("No."),'',PDFFileName,TRUE);
    

    now it will wait up to 10 seconds or until the file is found.

    Hope this helps.

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • BluefingerBluefinger Member Posts: 20
    Thanks ... Good idea! I will try something like that.
  • matttraxmatttrax Member Posts: 2,309
    On a related note, that will only work if you have BullZip as the default printer, or if that report is always set to go to BullZip in Printer Selections. You'll need some code to take care of that if that's not the case.
  • BluefingerBluefinger Member Posts: 20
    matttrax wrote:
    On a related note, that will only work if you have BullZip as the default printer, or if that report is always set to go to BullZip in Printer Selections. You'll need some code to take care of that if that's not the case.

    It's just a simplified code for now to make it work. There's a whole lot of other stuff still missing as well.

    thanks
Sign In or Register to comment.