VB Fax – Get an Outbound Fax Image
Download the VB fax (VB6) code samples.
Using the GetFaxImage method allows you to retrieve the image of an outbound (previously-submitted) fax in VB6.
This VB6 fax snippet retrieves an image of an outbound VB fax:
Attribute VB_Name = "GetFaxImage"
'
' This method retrieves the image of a VB fax from the Outbound service by calling the FaxQuery() method.
' The retrieved data is than saved to a local file
'
Option Explicit
Const TransactionID As Long = 129040055
Const FileName As String = "c:\temp\" & TransactionID & ".TIF"
Public Sub Invoke()
Dim ReturnCode As Long
Dim B() As Byte
Dim objEnv As PocketSOAP.CoEnvelope
Dim objHttp As PocketSOAP.HTTPTransport
Set objEnv = New PocketSOAP.CoEnvelope
objEnv.EncodingStyle = ""
objEnv.SetMethod "GetFaxImage", "http://www.interfax.cc"
objEnv.SerializerFactory.ElementMapping "buffer", "", "base64Binary", ""
Set objHttp = New PocketSOAP.HTTPTransport
objHttp.SOAPAction = "http://www.interfax.cc/GetFaxImage"
'
' Returns a chunck of data. Also returns the actual size of the returned data
'
objEnv.Parameters.Create "Username", Main.Username, objEnv.URI
objEnv.Parameters.Create "Password", Main.Password, objEnv.URI
objEnv.Parameters.Create "TransactionID", TransactionID, objEnv.URI
objHttp.send "https://ws.interfax.net/DFS.asmx", objEnv.Serialize
objEnv.EncodingStyle = ""
objEnv.parse objHttp
Dim GetFaxImageResult As PocketSOAP.CoSoapNode
Set GetFaxImageResult = objEnv.Parameters.itemByName("GetFaxImageResult", objEnv.URI)
If GetFaxImageResult.Value 0 Then
MsgBox ("Bad status=" & GetFaxImageResult.Value)
Exit Sub
End If
Dim Image As PocketSOAP.CoSoapNode
Set Image = objEnv.Parameters.itemByName("Image", objEnv.URI)
'
' The SOAP engine seems to not properly handle the returned value, which is Base64-encoded.
' Thus a decoding is done by the DecodeBase64 method.
'
If Not Utils.DecodeBase64(Image.Value, B) Then
MsgBox "Could not get or decode buffer"
Exit Sub
End If
' Save to file
Utils.WriteBinaryFile FileName, B
MsgBox "Saved as " & FileName
Set objEnv = Nothing
Set objHttp = Nothing
End Sub