无法使用VB.NET发送传真

时间:2016-05-18 22:19:29

标签: vb.net fax

我正在尝试编写一些从我的计算机发送传真的代码,我使用的是VB.NET桌面应用程序..

这是我的代码

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try
        Dim objFaxDocument As New FAXCOMEXLib.FaxDocument
        Dim objFaxServer As New FAXCOMEXLib.FaxServer
        Dim objSender As FAXCOMEXLib.FaxSender = Nothing
        Dim JobID As Object

        objFaxServer.Connect("")
        objFaxDocument.Priority = FAXCOMEXLib.FAX_PRIORITY_TYPE_ENUM.fptHIGH
        objFaxDocument.Body = "c:\invoice.txt"
        objFaxDocument.DocumentName = "My First Fax"
        objFaxDocument.Recipients.Add(stringPhoneNumber, "the man with the money")
        objFaxDocument.AttachFaxToReceipt = True

        objFaxDocument.Note = "first text fax of the day in vb"

        objFaxDocument.Subject = "testing fax system in vb"

        JobID = objFaxDocument.ConnectedSubmit(objFaxServer)
        MsgBox("The Job ID is :" & JobID(0))

    Catch ex As Exception
        MsgBox("Error number: " & Hex(Err.Number) & ", " & Err.Description)
    End Try


End Sub

现在,当我按下按钮时,代码运行没有问题,我得到了jobID,但我的收件人传真机没有收到传真。

我的计算机上有一个传真调制解调器,我将电脑与电话线连接起来。我将传真发送到与传真机连接的另一条线路。我的电脑运行Windows 7 ultimate(64位)。

1 个答案:

答案 0 :(得分:0)

首先检查Windows服务传真是否正在运行。

然后可能会有更多关于属性的数据会有所帮助。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
    Dim objFaxDocument As New FAXCOMEXLib.FaxDocument
    Dim objFaxServer As New FAXCOMEXLib.FaxServer
    Dim objSender As FAXCOMEXLib.FaxSender = Nothing
    Dim JobID As Object

    objFaxServer.Connect("")
    objFaxServer.Folders.OutgoingQueue.Retries = 0  
    objFaxServer.Folders.OutgoingQueue.Save() 
    objFaxServer.ListenToServerEvents(FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE)


    objFaxDocument.Priority = FAXCOMEXLib.FAX_PRIORITY_TYPE_ENUM.fptHIGH
    objFaxDocument.Body = "c:\invoice.txt"
    objFaxDocument.DocumentName = "My First Fax"
    objFaxDocument.Recipients.Add(stringPhoneNumber, "the man with the money")
    objFaxDocument.AttachFaxToReceipt = True

    objFaxDocument.Note = "first text fax of the day in vb"

    objFaxDocument.Subject = "testing fax system in vb"
    objFaxDocument.ScheduleType = FAXCOMEXLib.FAX_SCHEDULE_TYPE_ENUM.fstNOW 

    objFaxDocument.Sender.Name= "John Doe"
    objFaxDocument.Sender.FaxNumber= "John Doe number"
    objFaxDocument.Sender.Title= "My Fax"

    objFaxDocument.CoverPage = "Generic"
    objFaxDocument.CoverPageType = FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptNONE
    objFaxDocument.Note = "Text message"
    objFaxDocument.Sender.SaveDefaultsender()

    JobID = objFaxDocument.ConnectedSubmit(objFaxServer)
    MsgBox("The Job ID is :" & JobID(0))

Catch ex As Exception
    MsgBox("Error number: " & Hex(Err.Number) & ", " & Err.Description)
End Try

End Sub