Tech Off Post

Single Post Permalink

View Thread: COM Interop Question regarding FAXCOMEXLib
  • User profile image

    Can anyone please give me some help regarding how do you handle events for 
    FaxServer through .NET ie C# . My problem is I would like my application to be notified of the events that have been fired. I can't get the events to fire.
    Once I have called connectSubmit I would like the event, 
    FaxServer_OnOutgoingJobChanged to be fired so I can view the status of the fax on wheather it has been sent or an error eg. Incorrect fax number, no dial tone on the receiver etc.

    Also, I can't this to work with either a console app or a winforms app.
    I have tried to use WaitHandle etc with no success. Below is the following
    code, This code does include the waitHandle object :-
    using System;
    using FAXCOMEXLib;   // COM32
    namespace MyFax
       public class Fax
           private FAXCOMEXLib.FaxServer _faxServer;
           private IFaxDocument _docToFax; 
            public FAXCOMEXLib.FaxServer FaxServer
     get{return _faxServer;  }
     set{_faxServer = value;  }
            public IFaxDocument Document
     get{return _docToFax;  } 
     set{_docToFax = value;  }
          public virtual void SendFax()
              object jobId;
              FaxServer = new FaxServerClass();
              Document = new FaxDocumentClass(); 
           FaxServer.OnOutgoingJobChanged += new    
         Document.Body = _fileToFax; // tiff file to fax
         Document.DocumentName = _nameOfDocument;
         Document.Priority  = FAX_PRIORITY_TYPE_ENUM.fptHIGH;
         Document.Recipients.Add(FaxNumber, Recipient);
         Document.AttachFaxToReceipt = true;
         Document.ReceiptType = FAX_RECEIPT_TYPE_ENUM.frtNONE;
    /************************************************* */
    // HOW TO HANDLE THIS EVENT. FAX Console/ dialer starts up
    // however once this app has started up it then returns back to and  
    // assigns a jobid and continues on. My question is how to stop this from      
    // continuing on until I get a event from OnOutgoingJobChanged.
    /* ****************************************************** */
         jobId = Document.ConnectedSubmit(FaxServer);
       public void FaxServer_OnOutgoingJobChanged(FaxServer pFaxServer, string 
    bstrJobId, FaxJobStatus pJobStatus)
           // code to to log etc that a Fax event has occurred.
       public Fax()
          FaxServer = new FaxServerClass();
          Document= new FaxDocumentClass();