Sales
Click for numbers
Welcome User Tools Developer Tools Prices Help Sign up Login
You are here: Home > Developer Tools > Fax Web Service > Samples > VB6 - How to send a binary file

Fax Web Service Code Sample

VB6 - How to send a binary file

Download the associated project files.

' Sample of using InterFAX binary files
' Warning: No error handling is provided in this sample...
'
Const WSDL = "http://ws.interfax.net/dfs.asmx?WSDL"
' To achieve a better performance, it is HIGHLY recommended to
' save the WSDL as a LOCAL file, thus eliminatig the need to
' download it before EACH access to InterFAX. In such case,
' replace the CONST statement with something like:
' Dim WSDL as string
' WSDL = App.Path & "\DfsWsdl.wsdl"
'
Private Sub cmdSend_Click()

Dim B() As Byte
Dim objSoap As New MSSOAPLib.SoapClient
Dim lngResult As Long
Dim strFileType As String
'
' Obtain file type
'
strFileType = Mid(txtFilename.Text, InStrRev(txtFilename.Text, ".") + 1)
'
' Read binary file data
'
Open txtFilename.Text For Binary Access Read Lock Read As #1
ReDim B(LOF(1) - 1) 'Keep enough space to read the entire file to memory
Get #1, , B
Close #1
'
' Initialize SOAP
'
objSoap.mssoapinit (WSDL)
'
' Submit the fax the data
'
lngResult = objSoap.SendFAX(txtUserName.Text, txtPassword.Text, txtFaxNumber.Text, B, strFileType)
'
' Display result
'
If lngResult > 0 Then
MsgBox "Fax submitted; TransactionID=" & lngResult
Else
MsgBox "Failed to submit fax; Error code=" & lngResult
End If
'
' Clean up
'
Set objSoap = Nothing

End Sub



Note: If you are faxing from behind a proxy using MS SOAP v.3, you can use one of the two following options:

Option 1 - Use automatic detection by:
     objSoap.ConnectorProperty("EnableAutoProxy") = True

Option 2 - Specify a proxy server:
     objSoap.ConnectorProperty("ProxyServer") = "192.168.0.100"
and optionally, if the proxy server is password-protected specify:
     objSoap.ConnectorProperty("ProxyUser") = "Proxy Username"
     objSoap.ConnectorProperty("ProxyPassword") = "Proxy Password"




About | Contact | Privacy | Terms | Partners | Login | System Status

© Interfax Inc