Search code examples
c#fax

How to "Receive a Fax Now" using FAXCOMEXLIB?


I can receive and send fax using FAXCOMEXLIB in C#. example:

nws.faxSrv = new FaxServerClass();
nws.faxSrv.Connect(serverName);nws.faxSrv.ListenToServerEvents(FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE | FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetIN_QUEUE);
nws.faxSrv.OnOutgoingJobChanged += faxSrv_OnOutgoingJobChanged;
nws.faxSrv.OnOutgoingJobAdded += faxSrv_OnOutgoingJobAdded;
nws.faxSrv.OnOutgoingJobRemoved += faxSrv_OnOutgoingJobRemoved;

nws.faxSrv.OnIncomingJobAdded += faxSrv_OnIncomingJobAdded;
nws.faxSrv.OnIncomingJobChanged += faxSrv_OnIncomingJobChanged;
nws.faxSrv.OnIncomingJobRemoved += faxSrv_OnIncomingJobRemoved;

How can I use "Receive a Fax Now"? (windows fax have a "Receive a Fax Now" button).


Solution

  • use this:

     public void ReceiveFaxNow()
        {
            try
            {
                var device = nws.faxSrv.GetDevices().GetEnumerator();
                device.MoveNext();
                FaxDevice dev = (FaxDevice)device.Current;
    
                if (dev != null)
                {
                    dev.AnswerCall();
                }
            }
            catch (Exception e)
            {
    
            }
        }