Play Exchange 2010 Mailbox Items on Your Phone By Using the EWS Managed API
The Unified Messaging Play-On-Phone feature is now exposed through Exchange Web Services in Microsoft Exchange Server 2010. This feature is described in the EWS schema and WSDL files. What will be of more interest to you is that the Play-on-Phone feature is available in the Exchange Web Services Managed API 1.0. Now you can create custom applications that can read your mailbox items to you on your phone. The EWS Managed API implementation is very straightforward. Additionally, if you plan to handle the XML in your code, the EWS XML is also intuitive for customers who want to construct the XML with Microsoft .NET, Java, a scripting language, or any other language that can send and receive HTTP messages.
The following example shows EWS Managed API code that requests that an item be played on a phone, gets the status of the phone call, and then disconnects the phone call.
static void PlayItemOnPhone (ExchangeService service, ItemId itemId, string dialstring)
{
PhoneCall call = service.UnifiedMessaging.PlayOnPhone(itemId, dialstring);
Console.WriteLine("Call Number: " + dialstring);
Console.WriteLine("Call Status: " + call.State + "\n\r");
// Create a timer that will start immediately. Timer will call callback every 2 seconds.
Timer timer = new Timer(RefreshPhoneCallState, call, 0, 2000);
Console.WriteLine("PRESS ENTER TO END THE PHONE CALL AND CALL STATUS UPDATES");
Console.ReadLine();
// Disconnect the phone call if it is not already disconnected.
if (call.State != PhoneCallState.Disconnected)
{
call.Disconnect();
}
// Clean up the timer.
timer.Dispose();
}
// Callback method for refreshing call state for the phone call.
static void RefreshPhoneCallState(object pCall)
{
PhoneCall call = (PhoneCall) pCall;
call.Refresh();
Console.WriteLine("Call Status: " + call.State);
}
The PlayItemOnPhone method example has three parameters:
- Service - The service binding that identifies the URL of the Exchange Web Services endpoint.
- ItemId – The item identifier of the item that will be played on the phone.
- dialstring - The dial string of the phone number on which the item is played. The dial string can be set to an SMTP address so that the item is played on Microsoft Office Communicator.
The example uses three EWS operations: PlayOnPhone , GetPhoneCallInformation , and DisconnectPhoneCall . PlayOnPhone is called once, GetPhoneCallInformation may be called many times, and DisconnectPhoneCall may never be called, as the phone call can be disconnected by simply hanging up the phone (of course).
After you are connected to your mailbox via the Play-On-Phone feature, you have an entry point to Outlook Voice Access. After the item is read to you, you can enter the Outlook Voice Access feature. For more information about Outlook Voice Access, see Getting Started with Outlook Voice Access.
Try out the EWS Managed API Play-on-Phone feature in your next EWS client application.