example usage of FAXCOMEXLib in csharp dotnet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kagorami

    example usage of FAXCOMEXLib in csharp dotnet

    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.FAXCOME XLib.dll

    I added a reference to c:\windows\syst em32\fxscomex.d ll to the project,
    and it must translate to the above Interop.FAXCOME XLib.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.Componen tModel;
    using System.Collecti ons;
    using System.Runtime. InteropServices ;
    using System.Diagnost ics;
    using System.Threadin g;
    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.FaxDoc ument("C:\\Temp \\any file.txt", "911");
    }

    private int FaxDocument(Str ing TheFile, string faxnumber)
    {
    int JobID=0;
    FAXCOMEXLib.Fax Server faxsrv = new FAXCOMEXLib.Fax ServerClass();
    try
    {
    faxsrv.Connect( "");
    //Pick up the new changed document and fax it out.
    FAXCOMEXLib.Fax Document faxdoc = new
    FAXCOMEXLib.Fax DocumentClass() ;
    faxdoc.Body = TheFile;
    //Name the document
    faxdoc.Document Name = "Fax Transmission";
    faxdoc.ReceiptA ddress = "bob@doe.co m";
    FAXCOMEXLib.Fax Recipients frs = new
    FAXCOMEXLib.Fax RecipientsClass ();
    frs.Add(faxnumb er, "John Doe");
    faxdoc.Recipien ts = frs;
    faxdoc.Connecte dSubmit(faxsrv) ;
    }
    catch
    {
    }
    finally
    {
    faxsrv.Disconne ct();
    Marshal.Release ComObject(frs);
    Marshal.Release ComObject(faxdo c);
    Marshal.Release ComObject(faxsr v);
    }
    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

  • Alex Feinman [MVP]

    #2
    Re: example usage of FAXCOMEXLib in csharp dotnet

    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.Recipien ts.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" <digicate@netsp ace.net.au> wrote in message
    news:1121054851 .454339.292530@ g14g2000cwa.goo glegroups.com.. .[color=blue]
    > 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.FAXCOME XLib.dll
    >
    > I added a reference to c:\windows\syst em32\fxscomex.d ll to the project,
    > and it must translate to the above Interop.FAXCOME XLib.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.Componen tModel;
    > using System.Collecti ons;
    > using System.Runtime. InteropServices ;
    > using System.Diagnost ics;
    > using System.Threadin g;
    > 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.FaxDoc ument("C:\\Temp \\any file.txt", "911");
    > }
    >
    > private int FaxDocument(Str ing TheFile, string faxnumber)
    > {
    > int JobID=0;
    > FAXCOMEXLib.Fax Server faxsrv = new FAXCOMEXLib.Fax ServerClass();
    > try
    > {
    > faxsrv.Connect( "");
    > //Pick up the new changed document and fax it out.
    > FAXCOMEXLib.Fax Document faxdoc = new
    > FAXCOMEXLib.Fax DocumentClass() ;
    > faxdoc.Body = TheFile;
    > //Name the document
    > faxdoc.Document Name = "Fax Transmission";
    > faxdoc.ReceiptA ddress = "bob@doe.co m";
    > FAXCOMEXLib.Fax Recipients frs = new
    > FAXCOMEXLib.Fax RecipientsClass ();
    > frs.Add(faxnumb er, "John Doe");
    > faxdoc.Recipien ts = frs;
    > faxdoc.Connecte dSubmit(faxsrv) ;
    > }
    > catch
    > {
    > }
    > finally
    > {
    > faxsrv.Disconne ct();
    > Marshal.Release ComObject(frs);
    > Marshal.Release ComObject(faxdo c);
    > Marshal.Release ComObject(faxsr v);
    > }
    > 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
    >[/color]

    Comment

    Working...