如何生成传真并以代码形式发送

时间:2022-11-23 08:40:35

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.

我有业务要求生成传真并将其发送给收件人。我知道收件人姓名和传真号码,并附有PDF。此过程将每天运行,每次包含100条记录。我的印象是,这可以通过向传真机发送电子邮件来完成,并且Outlook中的快速测试工作得很好。但是,如果我尝试在代码中执行相同的操作,则会收到有关邮件地址无效的错误消息。

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...

从代码发送传真有哪些选择? (.NET)这些传真本质上是保密的......


EDITED INFO

My company does use Right Fax.

我的公司使用Right Fax。

4 个解决方案

#1


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

以下是一些可能有用的代码。这是使用右传真COM API库(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.

您可以使用Microsoft传真服务,但是您需要设置传真服务器.Google搜索应返回一些示例。

Add a reference to Interop.FAXCOMLib.dll

添加对Interop.FAXCOMLib.dll的引用

Here's an example (vb.net):

这是一个例子(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.

我们使用RightFax dll。只有在你的网络上有RightFax时,这才有效。

#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.

您也可以使用eFax,在这种情况下,您将PDF(传真文件)通过电子邮件发送给eFax,他们将为您传真!它们非常便宜。

#1


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

以下是一些可能有用的代码。这是使用右传真COM API库(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.

您可以使用Microsoft传真服务,但是您需要设置传真服务器.Google搜索应返回一些示例。

Add a reference to Interop.FAXCOMLib.dll

添加对Interop.FAXCOMLib.dll的引用

Here's an example (vb.net):

这是一个例子(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.

我们使用RightFax dll。只有在你的网络上有RightFax时,这才有效。

#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.

您也可以使用eFax,在这种情况下,您将PDF(传真文件)通过电子邮件发送给eFax,他们将为您传真!它们非常便宜。