简体   繁体   English

无法使用VB.NET发送传真

[英]Cannot send fax using VB.NET

I am trying to write some code that sends a fax from my computer, I am using VB.NET desktop application.. 我正在尝试编写一些从我的计算机发送传真的代码,我正在使用VB.NET桌面应用程序。

Here is my code 这是我的代码

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

Now, when I press the button, the code runs without problems, and I get the jobID, but the fax is not received in my recipient fax machine. 现在,当我按下按钮时,代码可以正常运行,并且我获得了jobID,但是接收方传真机中没有接收到传真。

I have a fax modem in the computer, and I connected the computer with the phone line. 我的计算机中有传真调制解调器,并且我已将计算机与电话线相连。 I send the fax to another line connected with fax machine. 我将传真发送到与传真机连接的另一条线路上。 My computer runs windows 7 ultimate (64-bit). 我的计算机运行Windows 7 Ultimate(64位)。

First check Windows Service Fax is running. 首先检查Windows服务传真是否正在运行。

Then maybe some more data on properties will help. 然后,也许更多有关属性的数据会有所帮助。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM