Microsoft example code doesn't work


Jeff Peatross

When I run this code:

Private Sub Form_Load()
Dim objFaxDocument As New FAXCOMEXLib.FaxDocument
Dim objFaxServer As New FAXCOMEXLib.FaxServer
Dim objSender As FaxSender
Dim JobID As Variant

'Error handling
On Error GoTo Error_Handler

'Connect to the fax server
objFaxServer.Connect ""

'Set the fax body
objFaxDocument.Body = "c:\Docs\Body.txt"

'Name the document
objFaxDocument.DocumentName = "My First Fax"

'Set the fax priority
objFaxDocument.Priority = fptHIGH

'Add the recipient with the fax number 12225550100
objFaxDocument.Recipients.Add "12225550100", "Bud"

'Choose to attach the fax to the fax receipt
objFaxDocument.AttachFaxToReceipt = True

'Set the cover page type and the path to the cover page
objFaxDocument.CoverPageType = fcptSERVER
objFaxDocument.CoverPage = "generic"

'Provide the cover page note
objFaxDocument.Note = "Here is the info you requested"

'Provide the address for the fax receipt
objFaxDocument.ReceiptAddress = "(e-mail address removed)"

'Set the receipt type to email
objFaxDocument.ReceiptType = frtMAIL

'Specify that the fax is to be sent at a particular time
objFaxDocument.ScheduleType = fstSPECIFIC_TIME
'CDate converts the time to the Date data type
objFaxDocument.ScheduleTime = CDate("4:35:47 PM")

objFaxDocument.Subject = "Today's fax"

'Set the sender properties.
objFaxDocument.Sender.Title = "Mr."
objFaxDocument.Sender.Name = "Bob"
objFaxDocument.Sender.City = "Cleveland Heights"
objFaxDocument.Sender.State = "Ohio"
objFaxDocument.Sender.Company = "Microsoft"
objFaxDocument.Sender.Country = "USA"
objFaxDocument.Sender.Email = "(e-mail address removed)"
objFaxDocument.Sender.FaxNumber = "12165555554"
objFaxDocument.Sender.HomePhone = "12165555555"
objFaxDocument.Sender.OfficeLocation = "Downtown"
objFaxDocument.Sender.OfficePhone = "12165555553"
objFaxDocument.Sender.StreetAddress = "123 Main Street"
objFaxDocument.Sender.TSID = "Office fax machine"
objFaxDocument.Sender.ZipCode = "44118"
objFaxDocument.Sender.BillingCode = "23A54"
objFaxDocument.Sender.Department = "Accts Payable"

'Save sender information as default

'Submit the document to the connected fax server
'and get back the job ID.

JobID = objFaxDocument.ConnectedSubmit(objFaxServer)

MsgBox "The Job ID is :" & JobID(0)
Exit Sub

'Implement error handling at the end of your subroutine. This
implementation is for demonstration purposes
MsgBox "Error number: " & Hex(Err.Number) & ", " & Err.Description

End Sub

It runs fine till the last line
JobID = objFaxDocument.ConnectedSubmit(objFaxServer)
and then I get the error code: 80070002, Operation Failed

This code came from:

Can anyone shed light?



I used the error number parsing technique Microsoft support recommends to
find out what the error really means. For your error number I got the
following message:

"The system cannot find the file specified." I guess something wrong with
the c:\Docs\Body.txt or may be with the application that is supposed to
handle the TXT extensions (usually Notepad.exe). Try to send a fax with an
empty body that only has a cover page. It's also possible that the cover page
file could not be found. Try sending a fax without a cover page to
troubleshoot this possibility. Hope this helps.

Now I get to ask my question. Hopefully MS folks read this sometimes and
will find time to answer it :)
My scenario is basically the same as Jeff described except I'm getting the
error code: 80070780, Operation Failed. Having that code translated into a
human's language (net helpmsg 1920) I got the following description:

"The file can not be accessed by the system."

This happens both on all tested Windows XP client machines as well as on the
Windows Server 2003 that is running FAX service but ONLY when a fax sent
programmatically using the FAXCOMEXLib library. If I print from any
application to that shared fax printer then I'm able to specify a fax number
via the Send Fax wizard that comes up and a fax goes out with no problems at
all. Anybody ha a clue? I will greatly appreciate any helpful suggestions!!!



OK. For anybody who is interested to hear the solution:

The problem has been fixed by re-installing the Fax Service on the Windows
Server 2003 fax server machine. It's weird but it worked. I would still want
to hear from Microsoft about the issue. Clearly the error message (80070780,
Operation Failed) that I was getting was not very helpful. With fax service
error messages MS definitely has a vast area for improvement. I'm glad it has
worked for us but I consider this a pure luck. Hope this comment will help
other folks wandering in the wild. I'm still hopeful that MS fax
service/FAXCOMExLib team will make improvements in the future. Thanks!

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question