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.
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.
来源:https://stackoverflow.com/questions/988340/how-to-generate-a-fax-and-send-it-in-code