How to Fax Nav Reports from Nav

ara3n
Member Posts: 9,258
Hello I've recently posted a blog on how to fax from Nav. Hopefully people find it useful.
Here is the link for detail explanation.
http://mibuso.com/blogs/ara3n/2009/06/1 ... amics-nav/
And the variables are.
Name DataType Subtype Length
FaxServer Automation 'Microsoft Fax Service Extended COM Type Library'.FaxServer
FaxDoc Automation 'Microsoft Fax Service Extended COM Type Library'.FaxDocument
JobID Text 30
FileName Text 100
Here is the link for detail explanation.
http://mibuso.com/blogs/ara3n/2009/06/1 ... amics-nav/
IF ISCLEAR(FaxServer) THEN CREATE(FaxServer); IF ISCLEAR(FaxDoc) THEN CREATE(FaxDoc); FaxServer.Connect(''); FileName := 'C:\test.rtf'; REPORT.SAVEASHTML(REPORT::"Top __ Customer List", FileName ,TRUE); FaxDoc.Body := FileName; FaxDoc.DocumentName := 'My Fax'; FaxDoc.Recipients.Add('17342351901'); //Fax Number FaxDoc.ConnectedSubmit(FaxServer);
And the variables are.
Name DataType Subtype Length
FaxServer Automation 'Microsoft Fax Service Extended COM Type Library'.FaxServer
FaxDoc Automation 'Microsoft Fax Service Extended COM Type Library'.FaxDocument
JobID Text 30
FileName Text 100
0
Comments
-
michelle123 wrote:I tired it, it worked.
Great work.Thanks
You are welcome.0 -
Thanks for the post. Great job.
The code works great. I use the code you posted for the PDFCreater and this code to fax invoices in a batch. I am just having one problem. When I do the batch the faxserver is opening up a adobe reader window for every fax and when it gets to about 30 windows it crashes.
Any ideas?tank0 -
I would use process of elimination to find out the cause.
First thing is to rule out adobe.
Instead of faxing pdf. try to fax a text file and see that you can batch fax 50 times.
If it is adobe, try to save the report as html. or get another software that opends pdf documents.0 -
I was able to send 100+ faxes. It took the program about 15 mins to load the fax server and all were sent in about 3 hours. Here is what I came up with. The OnRun() trigger for this codeunit calls a report five times that will only process 25 invoices at a time. The report calls the SendInvoiceFax() method for each invoice, flags the invoice headers as sent, and print the sent invoice information. Using the SHELL(taskkill) to kill adobe lets the batch keep running. Using it to kill pdfcreator allows the batch to keep running even if one of the invoices has a problem and doesn't create. I hope this might help someone.
Thanks again Rashed for all of your help,OnRun() CLEAR(FaxSalesInvoices); FaxSalesInvoices.USEREQUESTFORM(FALSE); FaxSalesInvoices.SetProperties('..' + FORMAT(WORKDATE)); FaxSalesInvoices.RUN; CLEAR(FaxSalesInvoices); SHELL('taskkill /F /IM AcroRd32.exe /T'); COMMIT; CLEAR(FaxSalesInvoices); FaxSalesInvoices.USEREQUESTFORM(FALSE); FaxSalesInvoices.SetProperties('..' + FORMAT(WORKDATE)); FaxSalesInvoices.RUN; CLEAR(FaxSalesInvoices); SHELL('taskkill /F /IM AcroRd32.exe /T'); COMMIT; CLEAR(FaxSalesInvoices); FaxSalesInvoices.USEREQUESTFORM(FALSE); FaxSalesInvoices.SetProperties('..' + FORMAT(WORKDATE)); FaxSalesInvoices.RUN; CLEAR(FaxSalesInvoices); SHELL('taskkill /F /IM AcroRd32.exe /T'); COMMIT; CLEAR(FaxSalesInvoices); FaxSalesInvoices.USEREQUESTFORM(FALSE); FaxSalesInvoices.SetProperties('..' + FORMAT(WORKDATE)); FaxSalesInvoices.RUN; CLEAR(FaxSalesInvoices); SHELL('taskkill /F /IM AcroRd32.exe /T'); COMMIT; CLEAR(FaxSalesInvoices); FaxSalesInvoices.USEREQUESTFORM(FALSE); FaxSalesInvoices.SetProperties('..' + FORMAT(WORKDATE)); FaxSalesInvoices.RUN; CLEAR(FaxSalesInvoices); SHELL('taskkill /F /IM AcroRd32.exe /T'); MESSAGE('ExpandIT Launch Utility Finished'); SendInvoiceFax(VAR SalesInvoiceHeader : Record "Sales Invoice Header";ReportID : Code[10]) FaxWasSent : Text[30] CLEARALL; FaxWasSent := 'Yes'; IF Customer.GET(SalesInvoiceHeader."Bill-to Customer No.") THEN BEGIN TempSting := '86' + DELCHR(Customer."A/R Fax No.",'=','-/()'); PhoneNo := DELCHR(TempSting,'=',DELCHR(TempSting,'=','1234567890')); //PhoneNo contains only numbers END ELSE PhoneNo := ''; IF (PhoneNo = '') OR (STRLEN(PhoneNo) <> 12) THEN BEGIN MESSAGE('ERROR Invalid Fax Number ' + FORMAT(SalesInvoiceHeader."No.")); SHELL('taskkill /F /IM AcroRd32.exe /T'); SHELL('taskkill /F /IM PDFCreator.exe /T'); EXIT('No / Invalid Fax No.'); END; IF ReportID = '' THEN ReportNo := 50138 //Sales Invoice 2 ELSE EVALUATE(ReportNo,ReportID); FileDirectory := 'E:'; FileName := FORMAT(SalesInvoiceHeader."No.") + 'fax'; FileName2 := FORMAT(SalesInvoiceHeader."No.") + 'fax.pdf'; IF ISCLEAR(PDFCreator) THEN CREATE(PDFCreator); IF ISCLEAR(PDFCreatorError) THEN CREATE(PDFCreatorError); PDFCreatorError := PDFCreator.cError; PDFCreator.cIsConverted := FALSE; IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN BEGIN MESSAGE('PDFCreator ' + FORMAT(SalesInvoiceHeader."No.")); SHELL('taskkill /F /IM AcroRd32.exe /T'); SHELL('taskkill /F /IM PDFCreator.exe /T'); EXIT('No / PDFCreater Error'); END; Object.GET(Object.Type::Report,'',ReportNo); 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; REPORT.RUNMODAL(ReportNo,FALSE,FALSE,SalesInvoiceHeader); TimeOut := 0; REPEAT SLEEP(1000); TimeOut := TimeOut + 1; UNTIL (PDFCreator.cIsConverted) OR (TimeOut = 25); IF TimeOut = 25 THEN BEGIN MESSAGE('Time Out Error ' + FORMAT(SalesInvoiceHeader."No.")); PDFCreator.cPrinterStop := TRUE; PDFCreator.cDefaultPrinter := DefaultPrinter; SHELL('taskkill /F /IM AcroRd32.exe /T'); SHELL('taskkill /F /IM PDFCreator.exe /T'); EXIT('No / Time Out Error'); END; PDFCreator.cPrinterStop := TRUE; PDFCreator.cDefaultPrinter := DefaultPrinter; PDFCreator.cClose; IF ISCLEAR(FaxServer) THEN CREATE(FaxServer); IF ISCLEAR(FaxDoc) THEN CREATE(FaxDoc); FileName := FileDirectory + '\' + FileName2; FaxDoc.Subject := SalesInvoiceHeader."No."; FaxDoc.Body := FileName; FaxDoc.DocumentName := SalesInvoiceHeader."Bill-to Customer No." + ' / ' + SalesInvoiceHeader.Name; FaxDoc.Recipients.Add(PhoneNo); //Fax Number FaxServer.Connect(''); FaxDoc.ConnectedSubmit(FaxServer); IF NOT EXISTS(FileName) THEN BEGIN MESSAGE('File Not Created Error ' + FORMAT(SalesInvoiceHeader."No.")); SHELL('taskkill /F /IM AcroRd32.exe /T'); SHELL('taskkill /F /IM PDFCreator.exe /T'); EXIT('No / PDF File Not Created'); END ELSE ERASE(FileName); CLEARALL;
tank0 -
You are welcome and thanks for sharing the code. And your experience.
I'm sure other people will find it useful.0 -
Hi,
Using your sample form i receive the following error:
The Call to member ConnectedSubmit Failed. FaxComEx.FaxDocument.1 returned thefollowing message: Operation Failed.
Does anyone know what this can be?
:-k0 -
Is your faxservice running?
Try to manually send a fax.0 -
the faxserver is running and manually it works.0
-
I don't know why you won't be able to connect to the server.
Try it on another computer.0 -
ara3n wrote:I would use process of elimination to find out the cause.
First thing is to rule out adobe.
Instead of faxing pdf. try to fax a text file and see that you can batch fax 50 times.
If it is adobe, try to save the report as html. or get another software that opends pdf documents.
Why would you rule out adobe? What kind of problems does it create?
Sorry I'm just learning about this stuff, and trying to get a better grasp on it.
Are there any other links on MS Fax Service that could help me learn more?
I've gotten a lot of help from Premium Corporate Internet Fax and Inexpensive Online Fax, so hope these links will be of help.
Thanks!
Taylor0 -
Does anybody know how to open the console/interface of the fax service while sending the fax? I don't want just to send the fax, i want to check manually if it is right and be able to see the preview.
Thanks0 -
It would be fine too if I could save the fax as a draft.
Thanks.0 -
What do you mean if it's right?
Why would it be wrong?0 -
What I mean Is that among the chosen invoices a wrong one could be, so I could see the preview of the faxes before they were sent I would be great for me. If manually I open the fax console => CLick NEW FAX => Then I can Save a copy in the draft folder to be sent later. When It's needed. Can I do the same thing with these faxes created by code?
Thanks.0 -
well you can code in NAV to see the Invoices before sending them to fax. Preview in NAV and then send the list of invoices to fax.0
-
Yes I know, but there's no need to do it with a new code since I have the preview of the chosen Invoices in the NAV Standard. Using the code you shared, I created a new Button (FAX) in the form 143. So when I choose the invoices to be sent, either by a filter or just clicking on with the mouse one by one, I can see the preview and then run the Fax Code. What I was looking for besides checking the faxes are correct, to modify (if needed) some of the fields of the fax as subject or note.
Never mind, I assume that can't be done. Thanks anyway, I learn a lot from you.0 -
HI ara3n,
I have quit New in FAX coding .
May i know your this I FAX coding does need match or specific to which window fax version?
Thanks and regards0 -
Still relevant today — I've had to fax NAV reports when integrating with older systems. If your clients don’t have direct email workflows, using a browser-based fax service like the ones here https://comfax.com/reviews/best-online-fax-services/ is a quick workaround. We exported reports as PDF and sent them out without touching a real fax machine. Might save some headaches for teams maintaining legacy integrations.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions