Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Still Trying to Fax from within VFP9 2

Status
Not open for further replies.

KimPP

Programmer
Jun 6, 2013
13
0
0
CA
Hi all,

I really appreciate all the help I've received so far, but I'm still hitting a snag in my attempt to send a fax through a dedicated fax SBS. Here is a snippet of my code:

SET OLEOBJECT ON
FaxServer = CREATEOBJECT("FaxServer.FaxServer")
&& FaxServer.CONNECT ("\\ntl-fsv-01\fax")
FaxServer.CONNECT ("\\ntl-fsv-01")
myFaxDocument = CREATEOBJECT("FaxComEx.FaxDocument")
&& myFaxDocument = CREATEOBJECT("FaxDocument.FaxDocument")
myFaxSender = myFaxDocument.Sender
myFaxSender.LoadDefaultSender()
myFaxDocument.Subject = "Test" && ie Report Title
myFaxDocument.Recipients.ADD("6139690470", "TEST") && ie faxnumber, receiptname
&& Suggested to help Debug
&& myFaxDocument.Submit()
&& back to program
faxPtrName = GETPRINTER()
&& SET PRINTER TO NAME ("\\ntl-fsv-01")
SET PRINTER TO NAME ("192.168.144.01")

On this last line, I get the message: "Error accessing printer spooler".

Can anyone think why this could be??

On a lower line of code,

myFaxDocument.Submit()

I get the error "OLE error 0x8002000e: Invalid number of parameters"

Again, I am stumped. Any help greatly appreciated!

Cheers,
Kim
 
Help clarify for me if by 'SBS' you mean Micro$oft's "Small Business Server" OS or something else.

I had a client sending FAX's via M$'s SBS Fax Server WAY BACK WHEN by using Outlook as the 'gateway' to the FAX Server.

If your "SBS' is something different - never mind.

Good Luck,
JRB-Bldr
 
You don't SEEM to have an actual fax document specified, you have a phone number and
the name of a recipient, even a title, but there does not seem to be any content...

So, I'm thinking there is an additional parameter (probably a filename for a .pdf or .tif or somesuch)
missing in there somewhere.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
What should SET PRINTER have to do with sending the fax. Your interface to the Fax is the FaxComEx.FaxDocument, not a printer, even if it is the fax, it will be operated by the FaxComEx.FaxDocument send or commit or whatever method to send the fax, not by SET PRINTER.

And in regard to this sample I found googling FaxComEx.FaxDocument, you have to set a Body property to the fax text:

Bye, Olaf.
 
Hi, again,

Thanks to all for your help. Turns out the error I'm getting, as I learned through research, is a Microsoft bug. Now I don't know what to do about that.

Yes, btw, I do mean Small Business Server.

 
With Small Business Server, I had each user install the FAX "Server" driver onto their own workstation to work as a "Printer".

Then within the Outlook I set them up with a FAX Service as one of Outlook's 'email' services.

Finally I had their VFP application automate Outlook to send the FAX's through that FAX Service and finally out a FAX/Modem device attached to the SBS Server box via its COM port.

And, until they got rid of SBS, it worked well for a number of years.

Good Luck,
JRB-Bldr


 
>Turns out the error I'm getting, as I learned through research, is a Microsoft bug
Are you sure Microsoft produces bugs, really.

Just kidding, of course any large enough software has bugs. Perhaps w could find a known or new workaround, but only if you tell us about the bug, where is it, what is it?

JRB-Bldr has sketched what could be done. If you don't need to automate a physical fax anyway, but a faxmodem hardware, outlook automation would be more to it than automating FaxComEx. From a german source code page I see the FaxServer object is FaxComEx.Faxserver, not FaxServer.FaxServer, as you used. Sounds plausible, doesn't it?

Bye, Olaf.
 
Thank you, that does sound plausible. I actually used FaxServerEx.FaxServer in one of my many versions of this program. I will plug that back in and give you an update.



 
btw, here is the code along with the suspected Microsoft bug-causing error:

SET OLEOBJECT ON
FaxServer = CREATEOBJECT("FaxServer.FaxServer")
&& FaxServer.CONNECT ("\\ntl-fsv-01\fax")
FaxServer.CONNECT ("\\ntl-fsv-01")
myFaxDocument = CREATEOBJECT("FaxComEx.FaxDocument")
&& myFaxDocument = CREATEOBJECT("FaxDocument.FaxDocument")
myFaxSender = myFaxDocument.Sender
myFaxSender.LoadDefaultSender()
myFaxDocument.Subject = "Test" && ie Report Title
myFaxDocument.Recipients.ADD("6139690470", "TEST") && ie faxnumber, receiptname
&& Suggested to help Debug
&& myFaxDocument.Submit()
&& back to program
faxPtrName = GETPRINTER()
&& SET PRINTER TO NAME ("\\ntl-fsv-01")
SET PRINTER TO NAME ("192.168.144.01")

on a lower line of code:

myFaxDocument.Submit() ** This is where I'm getting "OLE Error 0x8002000e: Invalid Number of Parameters **
So I looked this error up on the internet, finding that Microsoft has acknowledged it is caused by its own bug

Thoughts?



 
Well, what I find is the Submit parameter of the server name really is non optional, see
Intellisense also tells Submit() nad Submit2() both connect to, submit and disconnect from a Fax server. So how about trying it that way?

myFaxDocument.Submit("\\ntl-fsv-01\fax")

Your FaxServer object and FaxDocument also never use each other, so how would FaxServer.submit know you want to submit to "\\ntl-fsv-01\fax".

Bye, Olaf.
 
.. to add:

In the sample code I linked to earlier, FaxServer and FaxDocument object are used in conjunction in the almost final line

objFaxDocument.ConnectedSubmit(objFaxServer)

So this is what you also could try instead of myFaxDocument.Submit():

myFaxDocument.ConnectedSubmit(FaxServer)

Bye, Olaf.
 
Hi, Olaf,

Thank you so much for responding again! :)

I tried this line of code and got the following error:

0x8002005: Type mismatch

??

I really appreciate your help!



 
LOL, i tried both lines of code.

The first gave me the error message: Variable OBJFAXSERVER not found,

and the second gave the error mssg I mentioned above.



 
The line with objFaxServer was exactly copied from the VB sample, of course that doesn't work, you don't have such a variable.

I first gave another possible solution:
myFaxDocument.Submit("\\ntl-fsv-01\fax")

I'm just doing guesswork here, I am not having a Fax Server at hand to test things. But the code you have of course must fail, because you have a seperate FaxServer and FaxDocument object and they don't interact with each other.

I'm oblieged to suspect you didn't change FaxServer to be a FaxComEx.FaxServer object, instead of FaxServer.FaxServer. Of course the ConnectedSubmit method of the FaxComEx.FaxDocument class would expect a FaxComEx.FaxServer object as it's parameter, sounds plausible again, doesn't it?

Bye, Olaf.
 
Yes, I did change FaxComEx... lol

I shall try your other code, thanks so much!



 
I'd be glad, if that works for you. If it doesn't I'm afraid I'm out of ideas. You could just try the VB example as a VBScript, but that needs a bit more VB knowledge, as you can't use it 1:1 as a vbs file.

Again the link to the VB code sample:
Bye, Olaf.
 
Hi, again,

Have been working on other projects, but now have a deadline for the faxing program, so back at it!

Solved all previous issues, but now am left with one final error: OLE error x80020005: Type Mismatch

on the line reading:

myFaxDocument.ConnectedSubmit(FaxServer)

Here is more of the code:

&& PROGRAM: fax module get input
&&
&& This program allows the faxing of FoxPro generated reports from within
&& NesdaTrak. It clears the screen, asks user to select printer, and then
&& provides user prompts to get fields such as Sender Name, Recipient Name,
&& Fax number, Fax Title and Notes. The user is then told the fax has been
&& sent, detailing all the information the user provided.
&&
CLOSE ALL
CLEAR
SET SAFETY OFF
SET STEP ON
SET OLEOBJECT ON
&& Set up and open fax server
FaxServer = CREATEOBJECT("FaxServer.FaxServer")
&& FaxServer.CONNECT ("\\ntl-fsv-01\fax")
FaxServer.CONNECT ("\\ntl-fsv-01")
&& Initialize Fax Document Information
myFaxDocument = CREATEOBJECT("FaxComEx.FaxDocument")
&& myFaxDocument = CREATEOBJECT("FaxDocument.FaxDocument")
myFaxSender = myFaxDocument.Sender
myFaxSender.LoadDefaultSender()
myFaxDocument.Subject = "Test" && ie Report Title
myFaxDocument.Recipients.ADD("6139690470", "TEST") && ie faxnumber,receiptname
FaxPtrName = GETPRINTER()
SET PRINTER TO \\ntl-fsv-01\ \\SPOOLER\s=ntl-fsv-01
&& SET PRINTER TO NAME ("\\ntl-fsv-01")
&& SET PRINTER TO NAME ("192.168.144.01")
&& Code from Tia at Intrebare
FaxServer.Connect ("\\ntl-fsv-01")
&& Grab the report to send as the Fax Body
tmpFaxFile = "J:\sourcesv9\clients\nesdatrak\johndoesig.bmp" && ie Report itself from original program
myFaxDocument.body = (tmpFaxFile)

Then lower:

GETEXPR "Please enter Fax title: " TO title
INPUT "Please enter fax number: " TO faxnum
GETEXPR "Please enter Sender Name: " TO sendname
GETEXPR "Please enter Recipient Name: " TO receiptname
GETEXPR "Please enter any notes for cover page: " TO notes
&& Create the fax using the user inputs
myFaxDocument = CREATEOBJECT("FaxComEx.FaxDocument")
myFaxSender = myFaxDocument.Sender && ie sendname
&& myFaxSender.LoadDefaultSender() = sendname
&& myFaxDocument.Sender = sendname
&& myFaxDocument.Subject = "Test" && ie Report Title
&& myFaxDocument.Recipients.ADD("6139690470", "TEST") && ie faxnumber, receiptname
faxPtrName = GETPRINTER()
SET PRINTER TO faxPtrName
tmpFaxFile = "J:\sourcesv9\clients\nesdatrak\johndoesig.bmp" && ie report title
&& myFaxDocument.FaxNumber = faxnum
&& myFaxDocument.RecipientName = receiptname
myFaxDocument.recipients.add(faxnum, receiptname)
myFaxDocument.Body = (tmpFaxFile) && Grab the user-generated report
&& FaxDocument.ConnectedSubmit(FaxServer)
&& myFaxDocument.ConnectedSubmit(FaxServer)
RELEASE myFaxDocument
SET PRINTER TO DEFAULT
CLEAR

FaxServer.DISCONNECT()
FaxServer = .NULL.
CLEAR



Any help greatly appreciated, thank you!

Kim P
 
I can only repeat what I already pointed out two times.

This is your lines creating the FaxServer and the myFaxDocument variables:

Code:
FaxServer = CREATEOBJECT("FaxServer.FaxServer")
myFaxDocument = CREATEOBJECT("FaxComEx.FaxDocument")

This means you are using classes from Faxserver.DLL and FaxCOMEx.DLL, which can't work with each other.

To use the ConnectedSubmit method of a FaxComEx.FaxDocument you need a FaxComEx.FaxServer, not a FaxServer.FaxServer

That most probably explains the type mismatch. The type will be object in both cases, but that's just the foxpro variable type. The ConnectedSubmit doesn't work with any object, not even with any FaxServer object.

And again I have to point, I don't have such an environment to check out how this works and what changes would make it work, but what I can see is you're far off from what the VB sample does with the FoxComEX library classes.

What I can tell for sure is, that SET PRINTER is totally useless and unneeded, when using the FaxComEx library, it will not use a VFP printer setting.

Code:
faxPtrName = GETPRINTER()
SET PRINTER TO faxPtrName

Aside of FaxComEx not knowing of the printer VFP has set, The secnd line will try to set a printer named "faxptrName", literally, like SELECT somealias will select a workearea named "somealias", even if there is a variable called somealias, which has another alias name in it. To let SET PRINTER use the name you got from GETPRINTER(), you'd need to put the variable name into paranthesis to enforce an evaluation of it, so you would need SET PRINTER (faxPtrName). But the FaxComEx or the Faxserver libararies will neither make use of a printer, they represent the faxserver, and what it uses to fax is configured there, on the OS level in the Fax server. The set printer solution would just need a REPORT FORM, nothing more and nothing less. So neither the VFP reporting engine will have any knowledge about what you configure with Faxserver orr Faxdocument objects nor will these objects know anyhing about the printer you set in VFP.

Bye, Olaf.
 
thanks again for your sage advice.

I realized i'd rem'd out my "submit" command!

but now getting error:

OLE IDispatch erxception code 0 from FaxComEx.FaxDocument1: Operation Failed



My code is this:

myFaxDocument.ConnectedSubmit (FaxServer)


I've tried removing the "Connected" and I've tried putting in the actual printer name as a string. These only gave me syntax errors.

Any thoughts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top