How to generate a fax and send it in code

青春壹個敷衍的年華 提交于 2019-12-17 19:04:26

问题


I have a business requirement to generate a fax and send it to the recipient. I know the recipients name and fax number and there is a PDF that will be attached. This process will run daily and consist of 100 records to process each time. I was under the impression that this could be done by sending an email to the fax machine and a quick test in Outlook worked just fine. However, if I were to try and do the same thing in code, I get an error about the mail address being invalid.

MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress("[Fax:myUser@5555555555]"));

What are my options for sending faxes from code? (.NET) These faxes are confidential in nature...


EDITED INFO

My company does use Right Fax.


回答1:


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();



回答2:


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



回答3:


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




回答4:


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.



来源:https://stackoverflow.com/questions/988340/how-to-generate-a-fax-and-send-it-in-code

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