VB Fax – How to Retrieve the Status of an Outbound VB6 Fax with FaxQuery

25 Nov 2016 This code sample is deprecated and in process of being removed. Check out our new code libraries and usage documentation on InterFAX @ Github.
Download the VB fax (VB6) code samples.

This sample describes how to retrieve the status of an outbound VB fax using FaxQuery in VB6.

FaxQuery is a more advanced querying option compared to the FaxStatus method (see Side-by-side Comparison of Web Service Methods).

The VB fax code snippet below demonstrates the use of the outbound VB6 fax web Service’s FaxQuery method:


Attribute VB_Name = "FaxQuery"
'
' This method queries the user's VB fax log by calling FaxQuery() in VB6.
' A typical usage would be to get the information about a given transaction. This is done by specifying
' Verb as "EQ" and VerbData as the transaction ID.
'
' For extended query capabilities, use the FaxQuery2() method.
'
Option Explicit

Const Verb As String = "GE"
Const VerbData As String = "1000000"
Const MaxItems As Long = 10

Public Sub Invoke()

Dim i As Integer, j As Integer
Dim strOut As String

Dim objEnv As PocketSOAP.CoEnvelope
Dim objHttp As PocketSOAP.HTTPTransport

Set objEnv = New PocketSOAP.CoEnvelope

objEnv.EncodingStyle = ""

objEnv.SetMethod "FaxQuery", "http://www.interfax.cc"
objEnv.Parameters.Create "Username", Main.Username, objEnv.URI
objEnv.Parameters.Create "Password", Main.Password, objEnv.URI
objEnv.Parameters.Create "Verb", Verb, objEnv.URI
objEnv.Parameters.Create "VerbData", VerbData, objEnv.URI
objEnv.Parameters.Create "MaxItems", MaxItems, objEnv.URI
objEnv.Parameters.Create "ResultCode", 0, objEnv.URI   ' this is the In/Out parameter

Set objHttp = New PocketSOAP.HTTPTransport
objHttp.SOAPAction = "http://www.interfax.cc/FaxQuery"
objHttp.send "https://ws.interfax.net/DFS.asmx", objEnv.Serialize
objEnv.parse objHttp

Dim ResultCode As PocketSOAP.CoSoapNode
Set ResultCode = objEnv.Parameters.itemByName("ResultCode", objEnv.URI)

If ResultCode.Value  0 Then
    MsgBox ("Bad status=" & ResultCode.Value)
    Exit Sub
End If

Dim FaxQueryResult As PocketSOAP.CoSoapNode
Set FaxQueryResult = objEnv.Parameters.itemByName("FaxQueryResult", objEnv.URI)

Dim FaxItemEx As PocketSOAP.CoSoapNode
For i = 0 To FaxQueryResult.Nodes.Count - 1
    Set FaxItemEx = FaxQueryResult.Nodes.Item(i).Value
    strOut = ""
    For j = 0 To FaxItemEx.Nodes.Count - 1
        strOut = strOut & FaxItemEx.Nodes.Item(j).Name & ": " & FaxItemEx.Nodes.Item(j).Value & vbCrLf
    Next
    MsgBox strOut
Next

Set objEnv = Nothing
Set objHttp = Nothing
End Sub