tags:

views:

1487

answers:

5

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:[email protected]]"));

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


EDITED INFO

My company does use Right Fax.

A: 

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
NYSystemsAnalyst
A: 

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.

Andrew Siemer
I'm not sure I would trust documents "confidential in nature" to a faxing service.
Michael Todd
+1  A: 

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

Justin Balvanz
and where do you get RightFax.dll?
Jon Erickson
+1  A: 

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();
Jon Erickson
A: 

Hey guys I can use some help with this, I currently have RightFax but need to write a code so I can send out faxes. I am new to this and I hate to say this but I am no programmer.

any suggestions or help

Thanks in advance

Express
This should be a question by itself, because it is not an answer and no one will see it here.
Brad Larson
@Express: Brad is correct, this would be better as a how do I get started with... question or as a comment on this thread. But you're new to SO, so welcome! Do you have any funds or a budget for this project?
RSolberg
I apologize Brad and RSolberg, I will post as a new question. No I dont have a budget or fund for this. I have the existing pieces which I think I need. I just need help in getting it going. Thanks again .
Express