HOWTO: Using the Zetafax API from Visual Basic
Print
ZTN1068
ID: ZTN1068
This Zetafax technical note applies to:
Summary
This technical note gives an example of using the Zetafax API from a Visual Basic program.
More information
The Zetafax API includes a DLL, containing a number of functions which allow programs to submit faxes, and to monitor and control the fax queue.
Although these functions are documented as "C language callable functions", a Visual Basic header file is also supplied to allow then to be used from Visual Basic programs.
The Visual Basic function in this technical note uses Zetafax API callable functions to take fax addressing as arguments and uses these to automate the submission of a fax.
Example
Option Explicit
Function SendFax(strUserName As String, strFax As String, strName As String, strOrg As String, strSubject As String, strMsg As String) As Boolean
' This function uses the API to send a simple Fax message
On Error GoTo send_error
Dim iErr As Integer
Dim lSession As Long
Dim lError As Long
Dim iExclusive As Integer
Dim strBody As String * 9
Dim strFrom As String
lError = 0
iExclusive = 0
SendFax = False
'Initialise the API session
iErr = ZfxAPIInit(lSession, ByVal strUserName, ByVal 0, ByVal 0)
If iErr = 0 Then
'Create the submit file
Open " temp.txt" For Output As #1
Print #1, " %%[MESSAGE]"
Print #1, " SUBJECT: " & strSubject
Print #1, " To: " & strName
Print #1, " Organisation: " & strOrg
Print #1, " Fax: " & strFax
Print #1, " "
Print #1, " %%[TEXT]"
Print #1, strMsg
Close #1
'Submit the file
iErr = ZfxSendSubmitFile(lSession, ByVal " temp.txt" , ByVal " test" , ByVal strBody)
If iErr < > 0 Then
MsgBox " ZfxSendSubmitFile error: " & Hex(iErr), vbExclamation
Else
MsgBox " Message Sent OK: " & strBody, vbInformation
End If
'Finally tidy everything up
iErr = ZfxAPIClosedown(lSession)
Else
'Handle initialisation failure
MsgBox " ZfxAPIInit failed with error: " & Hex(iErr), vbExclamation
Exit Function
End If
SendFax = True
send_tidyup:
Exit Function
send_error:
MsgBox Err.Description, vbExclamation
Resume send_tidyup
End Function
References
For more information on using C language callable functions see the Zetafax API Help section of the ZFSetup.chm file, this can be accessed using the Configuration program.
Last updated: 15 May 2000 (GC/GW)