K
kagorami
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 = "(e-mail address removed)";
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
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 = "(e-mail address removed)";
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