FAXCOMEX to monitor outbound fax jobs

M

Martin

I'm trying to monitor outbound fax jobs using FAXCOMEX
"ListenToServerEvents". Currently I am logging inbound and outbound events
and it seems to be working fine, logging to a text file. But my goal here is
to be able to query the fax job on "OnOutgoingJobRemoved". This way I have
the status of the fax job that was submitted.

When I add code to get fax jobs on my "objFaxServer_OnOutgoingJobRemoved"
sub, nothing happens? Its strange because the only thing the subs does is
log the outgoing event. I would eventually want the event to call a sub
within my class.

Can someone help?

Here is the code:

Public WithEvents objFaxServer As New FAXCOMEXLib.FaxServer
Dim pJobStatus As FAXCOMEXLib.FaxJobStatus
Dim objFaxOutgoingQueue As FAXCOMEXLib.FaxOutgoingQueue
Dim objFaxOutgoingJob As FAXCOMEXLib.FaxOutgoingJob

Public Function faxlog(ByVal item1 As String)
Dim fso5, fil5
fso5 = CreateObject("Scripting.FileSystemObject")
fil5 = fso5.opentextfile("c:\Program Files\fMON\fMONlog.txt", 8, True, )
fil5.writeline(CStr(Now) & Chr(9) & item1)
fil5.Close()
fil5 = Nothing
fso5 = Nothing
End Function

Protected Overrides Sub OnStart(ByVal args() As String)
faxlog("Initialising class..")
On Error GoTo Error_Handler
faxlog("Class is initialised..")
objFaxServer.Connect("")
faxlog("Connected to local fax system..")
objFaxServer.ListenToServerEvents(FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fs
etOUT_QUEUE)
faxlog("Listening for queued fax events..")
'faxlog(Err.Description)
Exit Sub
Error_Handler:
faxlog("Class is initialised error")
End Sub

Private Sub objFaxServer_OnOutgoingJobAdded(ByVal pFaxServer As
FAXCOMEXLib.FaxServer, ByVal bstrJobId As String) Handles
objFaxServer.OnOutgoingJobAdded
faxlog("Job added to outbound queue..")
End Sub

Private Sub objFaxServer_OnOutgoingJobChanged(ByVal pFaxServer As
FAXCOMEXLib.FaxServer, ByVal bstrJobId As String, ByVal pJobStatus As
FAXCOMEXLib.FaxJobStatus) Handles objFaxServer.OnOutgoingJobChanged
'Error handling
'On Error GoTo Error_Handler
'Display the FaxJobStatus object's properties when the event is called
'faxlog("Fax " & pJobStatus.Subject & " was successfully sent to " &
pJobStatus.Recipient & " at " & pJobStatus.CallerId & ".")
'faxlog(pJobStatus.AvailableOperations & _
'vbCrLf & "Fax " & pJobStatus.Subject & " was successfully sent to " &
pJobStatus.Recipient & " at " & pJobStatus.CallerId & "." & _
'vbCrLf & "Sender: " & pJobStatus.Sender & _
'vbCrLf & "Fax submitted: " & pJobStatus.SubmissionTime & _
faxlog("Transmission started: " & pJobStatus.TransmissionStart & _
vbCrLf & vbTab & vbTab & vbTab & "Number of retries: " & pJobStatus.Retries
& _
vbCrLf & vbTab & vbTab & vbTab & "Number of pages: " & pJobStatus.Pages)
'Display the transmission end time separately, as this will cause an error
'while the transmission is still in progress
' faxlog("Transmission end: " & pJobStatus.TransmissionEnd)
' Exit Sub
'Error_Handler:
' Implement error handling at the end of your subroutine. This
implementation is for demonstration purposes
' faxlog("Error number: " & Hex(Err.Number) & ", " & Err.Description)
End Sub

Private Sub objFaxServer_OnOutgoingJobRemoved(ByVal pFaxServer As
FAXCOMEXLib.FaxServer, ByVal bstrJobId As String) Handles
objFaxServer.OnOutgoingJobRemoved
faxlog("Job removed from outbound queue..")
objFaxOutgoingQueue = objFaxServer.Folders.OutgoingQueue
MsgBox("There are " & objFaxOutgoingQueue.GetJobs.Count & " faxes in the
outgoing queue")
End Sub
 
A

Alex Feinman [MVP]

When you get OnOutgoingJobRemoved, the Job is already removed from the
OutgoingQueue
You can use objFaxServer.Folders.OutgoingArchive.GetMessage(JobID) to get
FaxOutgoingMessage object
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top