AddTapi.NET Developer's Manual
Answer Method
NamespacesTraysoft.AddTapiTapiCallAnswer()()()
Answers incoming call.
Declaration Syntax
C#Visual BasicVisual C++
public void Answer()
Public Sub Answer
public:
void Answer()
Remarks

AddTapi.NET answers all incoming calls automatically if RingsToAnswer is greater than zero. The application can set RingsToAnswer to zero and use Answer method if it needs to answer specific calls instead of all calls.

Answer is an asynchronous operation. Answer method requests the call to be answered and returns immediately. Telephony hardware will answer the call within a few seconds after the Answer call. AddTapi.NET fires CallConnected event and executes TapiCallHandler passed to Open(Boolean, TapiCallHandler) when the call is answered and connection is established.

Examples
The following code shows how to use Answer method to answer calls from a specific number. The error handling was omitted for clarity.

C#

            TapiApp.Initialize("MyApp");
            TapiApp.IncomingCall += OnIncomingCall;
            TapiLine line = TapiApp.Lines[0];
            line.Open(true, CallHandler);
            line.RingsToAnswer = 0;
            ...
            
            void OnIncomingCall(object sender, TapiEventArgs args)
            {
                TapiCall call = args.Call;
                // Answer calls from 555-123-4567
                if (call.CallerID == "5551234567")
                {
                    call.Answer();
                }
            }
            
            // This method will be called when incoming call is answered
            private void CallHandler(TapiCall call)
            {
                call.Play("welcome.wav");
                call.Speak("Press 1 to hear the current time. Press any other button to disconnect.");
                if(call.WaitForDigit(20) == "1")
                {
                    call.Speak(DateTime.Now.ToString());
                    call.WaitUntilDone(10);
                }
                call.Disconnect();
            }
            

VB.NET

            TapiApp.Initialize("MyApp")
            AddHandler TapiApp.IncomingCall, AddressOf OnIncomingCall
            Dim objLine As TapiLine
            objLine = TapiApp.Lines(0)
            objLine.Open(True, AddressOf CallHandler)
            objLine.RingsToAnswer = 0;
            ...
            
            Private Sub OnIncomingCall(ByVal sender As Object, ByVal args As TapiEventArgs)
                Dim objCall As TapiCall
                objCall = args.Call
                ' Answer calls from 555-123-4567
                If objCall.CallerID = "5551234567" Then
                    objCall.Answer()
                End If
            End Sub
            
            ' This method will be called when incoming call is answered
            Private Sub CallHandler(ByVal objCall As TapiCall)
                objCall.Play("welcome.wav")
                objCall.Speak("Press 1 to hear the current time. Press any other button to disconnect.")
                If objCall.WaitForDigit(20) = "1" Then
                    objCall.Speak(DateTime.Now.ToString())
                    objCall.WaitUntilDone(10)
                End If
                objCall.Disconnect()
            End Sub
            
Exceptions
ExceptionCondition
TapiExceptionThe call was not answered because a TAPI error occurred.
See Also

Assembly: Traysoft.AddTapi (Module: Traysoft.AddTapi)