Dear All,
I'm using PDFCreator to print and autosave pdf file and then using Codeunit 397 to auto send email to customer.
My problem is while PDFCreator is generating the PDF File, my outlook is sending the email(b4 pdfcreator finish generating the pdf) so it cant detect the attachment coz it's too fast(faster than PDFCreator). I tried using the SLEEP(20) to slower the report processing but it's failed below is my coding...help~~~
filename := 'C:\sentbox\tempFile.pdf';
testFile := EXISTS(filename);
IF testFile THEN BEGIN
myCust.RESET;
myCust.SETRANGE(myCust."No.","Sales Invoice Header"."Sell-to Customer No.");
IF myCust.FIND('-') THEN BEGIN
IF myCust."E-Mail" <> '' THEN BEGIN
EmailBody[1] := 'Regards,';
EmailBody[2] := 'IRG';
cr := 10;
lf := 13;
//BodyText := EmailBody[1]+FORMAT(cr)+FORMAT(lf)+EmailBody[2];
BodyText := EmailBody[1]+FORMAT(cr)+EmailBody[2];
mymail.NewMessage(myCust."E-Mail",'','Sales Invoice Report',BodyText,filename,FALSE);
mymail.Send();
END;
END;
END ELSE
MESSAGE('File not found');
0
Comments
The PDFCreator autmation has an event that is triggered once it's done. Create a single instance codeunit that will create the report. Make sure the automation variable has withevent enabled.
From your code call the single instance codeunit to print the report.
Inside the single instance codeunit you'll have a loop that will repeat until the event is triggered that is done. You can sleep inside the loop for a second.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I already enable the event..i think the event that u mean is PDF::eReady
I tried to put a MESSAGE('test') inside PDF::eReady() but it's not prompt the message at all..does tis mean the eReady event is not fire?
How to check whether the pdf file is generated? how to check the trigger whether it's fire or not?
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
10s for ur replied. May i know how to loop the instance/Code unit? coz i've no idea how to check the eReady whether it's fire or not?
Can u provide me a simple coding of looping the instance that check the eReady trigger? 10s a lot~
I managed to loop the codeunit/instance...using below code
OnRUN()
While myEReady = FALSE DO BEGIN
GetmyEReadyValue() //tis will return the myEready
END;
But the code above made my report hang....
And i use alternative way to implement it as below wihout looping:
Let say i print report in a batch.
Example Report A to Report C, and eReady only get fired when the Report C is completely generated. That mean system only able to send attached email to last recepient(Report C)
And i wish to send the report to recepient A & B as well....Any idea?
http://www.mibuso.com/forum/viewtopic.php?t=18331&highlight=
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Try something like
// PDFFile var of type FILE
Window.open('@');
REPEAT
counter += 1;
window.update(1,counter);
UNTIL PDFFile.OPEN(PDFDir + '\' + PDFFile) OR (Counter > 10000);
I have similar kind of requirement. I want to send the report
as an attachment( html or pdf) to the user, automatically when report gets
executed.
Can anybody tell me what code should i put. ](*,)
Senior Consultan
make a function.
SendEmail(Cust."No.",DateFilter,ReportId,ReportName,EmailIdList);
In this function
--> Check mail id list
--> Set file path (u can use by default Setup also)
--> REPORT.RUNMODAL(ReportId,FALSE,FALSE,Rec)
--> if report fails to run then generate error
OR make a failure table & generate a report from dat if u r
generating n sending reports to multiple customer (or Vendor)
-->set pdf printer (we used PDF995, PDF Creator, Amyuni)
--> CheckFileStatus
In this function u write a code to check whether file is ready or not.
As u know that Email function is too much fast, it will send an
corrupt file.
--> Using file function try to open it by code, if its get opened, close it
otherwise wait using sleep.
--> u can setup default wait time in company info card.
--> if filestatus returns true then send mail.
--> This works great, We made this one, installed for many clients. Even
we implemented Email, Fax together which generates reports for
multiple customer,vendor,contacts & send them at same time. U can
also save them in Draft or send it directly using automation control.
mErry chRisTmas 8)
Mahesh Jain
mahesh@reliconservices.com
Senior Consultan
Is any body can suggest how can I reset my default printer?
Thanks
Mini
The DefaultPrinter is copied to txt variable and then assigned at the end.
Are you doing that?
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I also write this code once email is send. But not working.:(
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n