Question

I'm going to create a fax application. I use Fax.Net project on codeplex.

When i try to send fax, if there was a fax account on machine, fax sent success but if there was no fax account, no fax gets sent.

Note: To create Fax Account using GUI, open Windows Fax and Scan, Tools, Fax Accounts... and press Add then follow Wizard.

Now i need to create a fax account programmatically in C#. How can i do this?

Was it helpful?

Solution

If you take a look at this MSDN page you'll see that adding an account programmatically
with FAXCOMExLib is trivial.

First you have to add the COM reference to your assembly. Search for "Microsoft Fax Service Extended COM Type Library" and then add the first one listed (fxscomex.dll). Make sure to add a using statement for FAXCOMEXLib in the source file the needs to reference it.

Here's a method that will create a new account and return an object for the new account. This could be changed to pass in a FaxServer object but I don't see a property to check connection state and that's why I just create a new server object instead.

/// <summary>
/// Create a new Fax Account on a windows fax server
/// </summary>
/// <param name="machineName">Empty string can be passed in to point to localhost fax server</param>
/// <param name="newAccountName"></param>
static FaxAccount CreateFaxAccount(string machineName, string newAccountName)
{
    FaxServer faxServer = new FaxServer();
    faxServer.Connect(machineName);
    FaxAccount newAccount = faxServer.FaxAccountSet.AddAccount(newAccountName);

    faxServer.Disconnect();
    return newAccount;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top