Ejemplo n.º 1
0
        // Callback method for refreshing call state for the phone call.
        private void RefreshPhoneCallState(object pCall)
        {
            PhoneCall call = (PhoneCall)pCall;

            call.Refresh();
            //string sAdd = "Call Status: " + call.State + "\r\n";
            //txtBody.Text += sAdd;  // TODO: need to get the body to display updates...
        }
        /// <summary>
        /// Callback method for refreshing call state for the phone call.
        /// </summary>
        /// <param name="pCall">The PhoneCall object that contains the call state.</param>
        static void RefreshPhoneCallState(object pCall)
        {
            PhoneCall call = (PhoneCall)pCall;

            // Update the phone call state. This results in a GetPhoneCallInformation operation call to EWS.
            call.Refresh();

            Console.WriteLine(DateTime.Now + " - Call Status: " + call.State);
        }
Ejemplo n.º 3
0
        } // End Sub ListAllMails

        /// <summary>
        /// Finds the first email message and initiates an attempt to call a phone number and
        /// dictate the contents of the email message. This sample requires that Unified Messaging
        /// is enabled for the caller.
        /// </summary>
        /// <param name="service">An ExchangeService object with credentials and the EWS URL.</param>
        public static void PlayEmailOnPhone(ExchangeService service)
        {
            /// <summary>
            /// Callback method for refreshing call state for the phone call.
            /// </summary>
            /// <param name="pCall">The PhoneCall object that contains the call state.</param>
            void RefreshPhoneCallState(object pCall)
            {
                PhoneCall phoneCall = (PhoneCall)pCall;

                // Update the phone call state. This results in a GetPhoneCallInformation operation call to EWS.
                phoneCall.Refresh();

                System.Console.WriteLine(System.DateTime.Now + " - Call Status: " + phoneCall.State);
            } // End Sub RefreshPhoneCallState

            // Find the first email message in the Inbox folder.
            ItemView view = new ItemView(1);

            view.PropertySet = new PropertySet(BasePropertySet.IdOnly);

            // Find the first email message in the Inbox. This results in a FindItem operation call to EWS.
            FindItemsResults <Item> results = service.FindItems(WellKnownFolderName.Inbox, view);

            try
            {
                string itemId     = results.Items[0].Id.UniqueId;
                string dialstring = "4255551212";

                // Initiate a call to dictate an email message over a phone call.
                // This results in a PlayOnPhone operation call to EWS.
                PhoneCall call = service.UnifiedMessaging.PlayOnPhone(itemId, dialstring);

                System.Console.WriteLine("Call Number: " + dialstring);
                System.Console.WriteLine(System.DateTime.Now + " - Call Status: " + call.State + "\n\r");

                // Create a timer that will start immediately. Timer will call callback every 2 seconds.
                using (System.Threading.Timer timer = new System.Threading.Timer(RefreshPhoneCallState, call, 0, 2000))
                {
                    System.Console.WriteLine("PRESS ENTER TO END THE PHONE CALL AND CALL STATUS UPDATES");
                    System.Console.ReadLine();

                    // Disconnect the phone call if it is not already disconnected.
                    if (call.State != PhoneCallState.Disconnected)
                    {
                        call.Disconnect();
                    }
                } // End Using timer

                System.Console.WriteLine("PRESS ENTER TO END CLOSE THIS WINDOW");
                System.Console.ReadLine();
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        } // End Sub PlayEmailOnPhone