423,319 Members | 2,562 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,319 IT Pros & Developers. It's quick & easy.

example usage of FAXCOMEXLib in csharp dotnet

P: n/a
G'Day,

I am searching for an example of using FAXCOMEXLib in csharp.

The COM interfaces are documented on msdn.microsoft.com however the
examples are for VB and c++.

Following up on a previous topic, FAXCOMEXLib is not in
FAXCOMEXLib.dll, but rather Interop.FAXCOMEXLib.dll

I added a reference to c:\windows\system32\fxscomex.dll to the project,
and it must translate to the above Interop.FAXCOMEXLib.dll

I am a little confused about adding a recipient to a fax document.

I have the fax document object, but the recipients member is
read-only?? So there must be another avenue for adding recipients that
I am yet to discover.

Here is my paltry code (based on code in another newsgroup for
FAXCOMLib)
<code>
using System;
using System.IO;
using System.ComponentModel;
using System.Collections;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using FAXCOMEXLib;

namespace csFaxComponent
{
public class csFax
{
protected FaxServer ofs = null;
public static void Main()
{
int JobID = 0;
csFax objcsFax = new csFax();
JobID = objcsFax.FaxDocument("C:\\Temp\\any file.txt", "911");
}

private int FaxDocument(String TheFile, string faxnumber)
{
int JobID=0;
FAXCOMEXLib.FaxServer faxsrv = new FAXCOMEXLib.FaxServerClass();
try
{
faxsrv.Connect("");
//Pick up the new changed document and fax it out.
FAXCOMEXLib.FaxDocument faxdoc = new
FAXCOMEXLib.FaxDocumentClass();
faxdoc.Body = TheFile;
//Name the document
faxdoc.DocumentName = "Fax Transmission";
faxdoc.ReceiptAddress = "bo*@doe.com";
FAXCOMEXLib.FaxRecipients frs = new
FAXCOMEXLib.FaxRecipientsClass();
frs.Add(faxnumber, "John Doe");
faxdoc.Recipients = frs;
faxdoc.ConnectedSubmit(faxsrv);
}
catch
{
}
finally
{
faxsrv.Disconnect();
Marshal.ReleaseComObject(frs);
Marshal.ReleaseComObject(faxdoc);
Marshal.ReleaseComObject(faxsrv);
}
return JobID;
}
}
}
</code>

I was able to send a fax using FAXCOM but I could not seem to get a
good status reply.

I will be faxing out several hundred documents generated by a mail
merge and if there is a problem faxing, then we want to fall back to a
printed/posted document. So the status/jobid is important.

Thanks,

Kim Groves
Accidental

Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
There is no need to release the COM wrapper object explicitly - garbage
collector copes with it just fine.

Adding recipients:
strig Phone = "333 555-7676";
FaxRecipient rcpt = faxDoc.Recipients.Add(phone, "Bob Recipient");

Finally, you'll find it very helpful to catch an exception and print it
instead of swallowing. For the period of initial debugging you might even
want to do away with try/catch and let the Studio to break on exception.
This way you know exactly where it happened

--
Alex Feinman
---
Visit http://www.opennetcf.org
"kagorami" <di******@netspace.net.au> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
G'Day,

I am searching for an example of using FAXCOMEXLib in csharp.

The COM interfaces are documented on msdn.microsoft.com however the
examples are for VB and c++.

Following up on a previous topic, FAXCOMEXLib is not in
FAXCOMEXLib.dll, but rather Interop.FAXCOMEXLib.dll

I added a reference to c:\windows\system32\fxscomex.dll to the project,
and it must translate to the above Interop.FAXCOMEXLib.dll

I am a little confused about adding a recipient to a fax document.

I have the fax document object, but the recipients member is
read-only?? So there must be another avenue for adding recipients that
I am yet to discover.

Here is my paltry code (based on code in another newsgroup for
FAXCOMLib)
<code>
using System;
using System.IO;
using System.ComponentModel;
using System.Collections;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using FAXCOMEXLib;

namespace csFaxComponent
{
public class csFax
{
protected FaxServer ofs = null;
public static void Main()
{
int JobID = 0;
csFax objcsFax = new csFax();
JobID = objcsFax.FaxDocument("C:\\Temp\\any file.txt", "911");
}

private int FaxDocument(String TheFile, string faxnumber)
{
int JobID=0;
FAXCOMEXLib.FaxServer faxsrv = new FAXCOMEXLib.FaxServerClass();
try
{
faxsrv.Connect("");
//Pick up the new changed document and fax it out.
FAXCOMEXLib.FaxDocument faxdoc = new
FAXCOMEXLib.FaxDocumentClass();
faxdoc.Body = TheFile;
//Name the document
faxdoc.DocumentName = "Fax Transmission";
faxdoc.ReceiptAddress = "bo*@doe.com";
FAXCOMEXLib.FaxRecipients frs = new
FAXCOMEXLib.FaxRecipientsClass();
frs.Add(faxnumber, "John Doe");
faxdoc.Recipients = frs;
faxdoc.ConnectedSubmit(faxsrv);
}
catch
{
}
finally
{
faxsrv.Disconnect();
Marshal.ReleaseComObject(frs);
Marshal.ReleaseComObject(faxdoc);
Marshal.ReleaseComObject(faxsrv);
}
return JobID;
}
}
}
</code>

I was able to send a fax using FAXCOM but I could not seem to get a
good status reply.

I will be faxing out several hundred documents generated by a mail
merge and if there is a problem faxing, then we want to fall back to a
printed/posted document. So the status/jobid is important.

Thanks,

Kim Groves
Accidental


Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.