Unable to capture fax service events

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All,
I have registered for fax service events on the page load of my form. But the event functions are not getting executed when I am sending or receiving a fax i,e adding a fax to the outgoing queue. I have used the below code. Please let me know if I am making
a mistake somewhere in the code. Any help is greatly appreciated.
<pre class="prettyprint lang-vb Public Class frmMain
Dim WithEvents g_objFaxServer As FAXCOMEXLib.FaxServer
Dim pJobStatus As FAXCOMEXLib.FaxJobStatus

Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Error handling
On Error GoTo Error_Handler

Initialize the FaxServer object
g_objFaxServer = New FAXCOMEXLib.FaxServer

Connect to the local fax server
g_objFaxServer.Connect(Environment.MachineName)

Now register for the desired events
g_objFaxServer.ListenToServerEvents( _
FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED + _
FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE)

From now on, if the fax service has stopped, the function
g_objFaxServer_OnServerShutDown() will be called, if a message is
added to the outgoing queue, g_objFaxServer_OnOutgoingJobAdded() will
be called, and if there is a change in the status of an outgoing job,
g_objFaxServer_OnOutgoingJobChanged() will be called
Exit Sub

Error_Handler:
Implement error handling at the end of your subroutine. This
implementation is for demonstration purposes
MsgBox("Error number: " & Hex(Err.Number) & ", " & Err.Description)
End Sub


Private Sub g_objFaxServer_OnOutgoingJobAdded(ByVal pFaxServer As FAXCOMEXLib.IFaxServer, _
ByVal bstrJobId As String)

MsgBox("New job added to queue")

End Sub

Private Sub g_objFaxServer_OnOutgoingJobChanged(ByVal pFaxServer As FAXCOMEXLib.IFaxServer, _
ByVal bstrJobId As String, ByVal pJobStatus As FAXCOMEXLib.IFaxJobStatus)
This event receives the FaxJobStatus object

Since this event is likely to result in errors, such as trying to
report the transmission end time before the transmission has ended,
this subroutine includes error handling

Error handling
On Error GoTo Error_Handler


Display the FaxJobStatus objects properties when the event is called
MsgBox(pJobStatus.AvailableOperations & _
vbCrLf & "Caller ID: " & pJobStatus.CallerId & _
vbCrLf & "CSID: " & pJobStatus.CSID & _
vbCrLf & "Current page: " & pJobStatus.CurrentPage & _
vbCrLf & "Device ID: " & pJobStatus.DeviceId & _
vbCrLf & "Extended status: " & pJobStatus.ExtendedStatus & _
vbCrLf & "Extended status code: " & pJobStatus.ExtendedStatusCode & _
vbCrLf & "Job type: " & pJobStatus.JobType & _
vbCrLf & "Pages: " & pJobStatus.Pages & _
vbCrLf & "Retries: " & pJobStatus.Retries & _
vbCrLf & "Routing information: " & pJobStatus.RoutingInformation & _
vbCrLf & "Scheduled time: " & pJobStatus.ScheduledTime & _
vbCrLf & "Size: " & pJobStatus.Size & _
vbCrLf & "Status: " & pJobStatus.Status & _
vbCrLf & "Transmission start: " & pJobStatus.TransmissionStart & _
vbCrLf & "TSID: " & pJobStatus.TSID)

Display the transmission end time separately, as this will cause an error
while the transmission is still in progress
MsgBox("Transmission end: " & pJobStatus.TransmissionEnd)

Exit Sub

Error_Handler:
Implement error handling at the end of your subroutine. This
implementation is for demonstration purposes
MsgBox("Error number: " & Hex(Err.Number) & ", " & Err.Description)
End Sub

Private Sub g_objFaxServer_OnServerShutDown(ByVal pFaxServer As FAXCOMEXLib.IFaxServer)

MsgBox("The local fax server has been shut down")

End Sub

End Class
[/code]
Thanks and regards,
Noor Hussain
<
Thanks & Regards, Noor Hussain

View the full article
 
Back
Top