SMS Messaging Using Twilio and Outlook 2010
Time to read: 3 minutes
In order to send and receive text messages, Outlook needs a service that conforms to the Office Mobile Service (OMS) guidelines. Building a .NET service that conform to these guidelines is made easy by using a standard ASMX Web Service and the Twilio .NET Helper Library.
Sending Text Messages using Outlook
The OMS guidelines describe how to use a basic SOAP web service to expose a standard set of endpoints that Outlook will call in order discover service and user information and send text messages.
At a high level, there are four methods an OMS service needs to expose:
- string GetServiceInfo() – Returns information about the service
- string GetUserInfo(string xmsUser) – Retrieves information about a user
- string DeliverXms(string xmsData) – Sends one mobile message
- string DeliverXmsBatch(string packageXml) – Sends multiple mobile messages in a batch
As Outlook calls each method it will pass in XML data which your service can parse in order to determine who is sending the message, what the body of the message is, and who the message is being sent to. An example of what Outlook passes to the DeliverXms method is below:
The configuration dialog has you enter the service URL and a username and password and then lets you test the service. Notice that the service provider URL uses and HTTPS address. The OMS guidelines specify that the service must be run using SSL, and Outlook always uses SSL to call the service.
If Outlook successfully connects to the service then you can start using to send text messages right from Outlook:
One very nice feature of Outlooks text message editor is that it automatically splits messages over 160 characters up into multiple text messages, which you see in the screen shot above.
Receiving Messages in Outlook
The OMS guidelines also include information on how to handle incoming text messages. As with creating the OMS service for sending messages, receiving messages is simple as well, especially when using Twilio.
Simply create an endpoint that Twilio can call when it receives a message. If you are using .NET, that endpoint can be and HTTP handler, an ASP.NET MVC Action method, or even a standard ASPX web page. The logic in that page can receive the message from Twilio, then forward it via email into Outlook.
In order for Outlook to know that the incoming email originated as an SMS message, it looks for certain headers in the mail message. These headers tell Outlook not only that the message source is a text message, but also include the information that Outlook needs in order to create a text message reply.
An Office Message Service Sample
In order to show a full sample on how to create a OMS service I have created the Twilio Office Message Service sample. The sample shows how to create the OMS service to send messages, handle incoming messages, and also includes a simple website that lets users provide their own Twilio credentials in order to use the service. You can grab the full source for the sample application from GitHub.
I’d love your comments or questions about building an OMS service for Outlook. Feel free to email me at devin@twilio.com or tweet me at @devinrader
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.