Reputation: 26972
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.
Upvotes: 3
Views: 11533
Reputation: 114916
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();
Upvotes: 6
Reputation: 1186
We use the RightFax dll. That will only work if you have RightFax on your network though.
Upvotes: 2
Reputation: 10278
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.
Upvotes: 0
Reputation: 12126
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
Upvotes: 1