Fax services not working

rosstheboss

New member
Joined
Aug 31, 2006
Messages
1
Programming Experience
Beginner
Hi,

i have written a piece of code that sends a fax from a vb.net program, this was taken from a VB program that does the same thing yet when transferred it does not work. I wish to find the status of the fax as it is being sent but an error occurs at the refresh line. Could someone please help. The code is as follows
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] contactFax[/SIZE]
[SIZE=2]contactFax = Replace(faxnum, " ", "")[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] FaxServer [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] FaxDoc [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] gstrServerName [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] JobId [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Long[/COLOR][/SIZE]
 
[SIZE=2]FaxServer = CreateObject("FaxServer.FaxServer")[/SIZE]
[SIZE=2]FaxDoc = FaxServer.CreateDocument("Fax")[/SIZE]
[SIZE=2]FaxDoc.Filename = filename[/SIZE]
[SIZE=2]FaxDoc.FaxNumber = contactFax[/SIZE]
[SIZE=2]FaxServer.Connect("edi01084")[/SIZE]
[SIZE=2]JobId = FaxDoc.Send()[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] FaxPorts [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] lCount [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Long[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] FaxPort [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] FaxStatus [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] status [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strDescrip [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oldStrDescrip [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2]i = 0[/SIZE]
[SIZE=2]FaxPorts = FaxServer.GetPorts()[/SIZE]
[SIZE=2]lCount = FaxPorts.Count[/SIZE]
[SIZE=2]FaxPort = FaxPorts.Item(lCount)[/SIZE]
[SIZE=2]FaxStatus = FaxPort.GetStatus()[/SIZE]
[SIZE=2]status = ""[/SIZE]
[SIZE=2]status = FaxStatus.Refresh()[/SIZE]
[SIZE=2]strDescrip = FaxStatus.Description[/SIZE]
[SIZE=2]oldStrDescrip = strDescrip[/SIZE]
[SIZE=2]Debug.Write(strDescrip & vbCrLf)[/SIZE]
[SIZE=2][COLOR=#008000]REM while the status is 'Unknown', 'Available', 'Initializing', 'Dialing' or 'Sending'...[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] strDescrip = "Unknown" [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] strDescrip = "Available" [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] strDescrip = "Initializing" [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] strDescrip = "Dialing" _[/SIZE]
[SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] strDescrip = "Sending" [/SIZE][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][SIZE=2] strDescrip = "Crashed!"[/SIZE]
[SIZE=2][COLOR=#008000]'On Error GoTo fail[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]On[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Error[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Resume[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[SIZE=2]status = FaxStatus.Refresh()[/SIZE]
[SIZE=2]strDescrip = FaxStatus.Description[/SIZE]
[SIZE=2]log.Text = strDescrip[/SIZE]
[SIZE=2]Application.DoEvents()[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] strDescrip = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]strDescrip = "Crashed!"[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] strDescrip <> oldStrDescrip [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]Debug.Write(strDescrip & vbCrLf)[/SIZE]
[SIZE=2]oldStrDescrip = strDescrip[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]i = i + 1[/SIZE]
[SIZE=2][COLOR=#008000]'System.Threading.Thread.Sleep(1000)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE]
[SIZE=2]FaxStatus = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]FaxPort = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]FaxPorts = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]FaxDoc = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]FaxServer.Disconnect()[/SIZE]
[SIZE=2]FaxServer = [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE]
[SIZE=2]i = 0[/SIZE]
[SIZE=2]fail:[/SIZE]
[SIZE=2]i = 0[/SIZE]
thanks
 
Last edited by a moderator:
Back
Top