How to generate a fax and send it in code

纵饮孤独 提交于 2019-11-28 09:32:59

Here is some code that may help. This is using the Right Fax COM API Library (rfcomapi.dll)

RFCOMAPILib.FaxServerClass faxserver = new RFCOMAPILib.FaxServerClass();
faxserver.ServerName = "ServerName";
faxserver.Protocol = RFCOMAPILib.CommunicationProtocolType.cpNamedPipes;
faxserver.UseNTAuthentication = RFCOMAPILib.BoolType.True;
faxserver.OpenServer();

RFCOMAPILib.Fax fax = (RFCOMAPILib.Fax) faxserver.get_CreateObject(RFCOMAPILib.CreateObjectType.coFax);

// set up your 'fax' object the way you want it, below is just some sample options
fax.ToName = "John Doe";
fax.ToFaxNumber = "4255551111";
fax.ToVoiceNumber = "4255550000";
fax.ToCompany = "ACME";
fax.FromName = "My Company";
fax.FromVoiceNumber = "4255552222";

fax.Send();

You can use the Microsoft Fax Service, but you will need to set up a fax server.. A Google search should return some examples.

Add a reference to Interop.FAXCOMLib.dll

Here's an example (vb.net):

    Dim fs As FAXCOMLib.FaxServer
    Dim fd As FAXCOMLib.FaxDoc
    Dim result As Integer

    fs = New FAXCOMLib.FaxServer()
    fs.Connect("FaxServer1")

    fd = CType(fs.CreateDocument("c:\documenttofax.pdf"), FAXCOMLib.FaxDoc)
    fd.RecipientName = "John Doe"
    fd.FaxNumber = "555-1234"

    Try
       result = fd.Send()
    Finally
        fs.Disconnect()
    End Try

We use the RightFax dll. That will only work if you have RightFax on your network though.

You can also use eFax in which case you email a PDF (the faxed document) to eFax and they will fax it for you! They are very cheap.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!