mibuso.com

Microsoft Business Solutions online community
It is currently Thu Oct 02, 2014 4:23 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How to Fax Nav Reports from Nav
PostPosted: Mon Jun 15, 2009 1:51 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 9051
Location: 3rd rock from sun
Country: United States (us)
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/

Code: Select all

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

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Tue Jun 23, 2009 1:40 pm 
Offline

Joined: Mon Mar 08, 2004 2:42 pm
Posts: 3255
Location: Hannover
Country: Germany (de)
yes michelle, it's very easy.

Here a LINK to the MSDN to learn more about MS Fax Service and to learn how to use it.

Regards

_________________
Do you make it right, it works too!


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Tue Jun 23, 2009 3:33 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 9051
Location: 3rd rock from sun
Country: United States (us)
michelle123 wrote:
I tired it, it worked.
Great work.Thanks


You are welcome.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Sat Sep 19, 2009 12:32 am 
Offline

Joined: Wed Oct 11, 2006 3:29 pm
Posts: 21
Location: Hopkinsville, Ky
Country: United States (us)
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?

_________________
tank


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Sat Sep 19, 2009 12:46 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 9051
Location: 3rd rock from sun
Country: United States (us)
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.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Fri Oct 23, 2009 4:48 pm 
Offline

Joined: Wed Oct 11, 2006 3:29 pm
Posts: 21
Location: Hopkinsville, Ky
Country: United States (us)
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,


Code: Select all

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;


_________________
tank


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Fri Oct 23, 2009 7:38 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 9051
Location: 3rd rock from sun
Country: United States (us)
You are welcome and thanks for sharing the code. And your experience.
I'm sure other people will find it useful.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Tue Apr 27, 2010 11:33 pm 
Offline

Joined: Sun Jan 07, 2007 11:08 pm
Posts: 63
Location: Holland
Country: Netherlands (nl)
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?

:-k


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Wed Apr 28, 2010 2:48 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 9051
Location: 3rd rock from sun
Country: United States (us)
Is your faxservice running?

Try to manually send a fax.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Wed Apr 28, 2010 8:33 am 
Offline

Joined: Sun Jan 07, 2007 11:08 pm
Posts: 63
Location: Holland
Country: Netherlands (nl)
the faxserver is running and manually it works.


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Fri Apr 30, 2010 8:35 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 9051
Location: 3rd rock from sun
Country: United States (us)
I don't know why you won't be able to connect to the server.

Try it on another computer.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Mon Nov 22, 2010 7:54 am 
Offline

Joined: Mon Nov 22, 2010 7:47 am
Posts: 1
Country: United States (us)
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!
Taylor


Top
 Profile E-mail  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Wed Feb 16, 2011 5:32 pm 
Offline

Joined: Mon Feb 14, 2011 1:30 pm
Posts: 6
Country: Spain (es)
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.
Thanks


Top
 Profile E-mail  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Thu Feb 17, 2011 9:32 am 
Offline

Joined: Mon Feb 14, 2011 1:30 pm
Posts: 6
Country: Spain (es)
It would be fine too if I could save the fax as a draft.
Thanks.


Top
 Profile E-mail  
 
 Post subject: Re: How to Fax Nav Reports from Nav
PostPosted: Thu Feb 17, 2011 4:07 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 9051
Location: 3rd rock from sun
Country: United States (us)
What do you mean if it's right?
Why would it be wrong?

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: