none
Sending a Fax using a windows service

    Question

  • I am working on a windows service that sends faxes when one has been loaded into a database.  When I run the service, the fax info gets picked up from the database and the service connects to the shared fax W2K8R2 server with no issues.  I get an error though on the .ConnectedSubmit(faxserverobj) call to send the fax.  The error is 800710D8, Operation failed.  What a great error!

    Funny thing is, i have the exact same code tested in a windows form application and it runs perfectly on the same machine that i'm trying to get the service to run on, so i know there is not a permissions issue and i verified that by logging the .CurrentAccount.AccountName that gets used by the object.  I also know that there is no issue with the pdf, i used the same file for the windows form app and it sends correctly.  My only thought is that there may be something i'm missing because this is within a service, but I also have an earlier version of code that ran against a W2003 server that worked.  I want to replace the 2003 server with a W2K8 server.  My code is below.  Any thoughts or help would be greatly appreciated.

            Dim faxserverobj As New FaxServer()
            Dim myfaxdoc As FaxDocument

            Dim MyCoverPageType As FAX_COVERPAGE_TYPE_ENUM

            faxserverobj.Connect(StrFaxHost)

            If strcoverpagetype = "fcptSERVER" Then
                MyCoverPageType = FAX_COVERPAGE_TYPE_ENUM.fcptSERVER
            Else
                MyCoverPageType = FAX_COVERPAGE_TYPE_ENUM.fcptNONE
            End If

            myfaxdoc = New FaxDocument()
            myfaxdoc.Recipients.Add(strrecipientnumber, strrecipientname)
            myfaxdoc.Sender.Name = strsendername
            myfaxdoc.Sender.Company = strsendercompany
            myfaxdoc.Sender.FaxNumber = strsenderfaxnumber
            myfaxdoc.Subject = strsubject
            myfaxdoc.DocumentName = strdocumentname
            myfaxdoc.Note = strnote
            myfaxdoc.CoverPage = strcoverpage
            myfaxdoc.CoverPageType = MyCoverPageType
            myfaxdoc.Priority = FAX_PRIORITY_TYPE_ENUM.fptNORMAL
            myfaxdoc.ReceiptType = FAX_RECEIPT_TYPE_ENUM.frtNONE
            myfaxdoc.ScheduleType = FAX_SCHEDULE_TYPE_ENUM.fstNOW

            myfaxdoc.Body = strbody  'This is a path to a pdf doc

            Dim myjobid() As Object
            
            myjobid = myfaxdoc.ConnectedSubmit(faxserverobj) ' This is where it fails in the service

            Dim jidindex As Integer
            For jidindex = 0 To UBound(myjobid)

                If BolFaxServiceIsLong = True Then
                    SendFax = myjobid(jidindex).ToString
                 Else
                     SendFax = Hex(myjobid(jidindex))
                End If

            Next

            myfaxdoc = Nothing
            faxserverobj.Disconnect()
            faxserverobj = Nothing

    Thursday, April 27, 2017 7:17 AM

All replies