Capture Incoming SMS Opt-Ins Into an Excel Database

The following is a simple example for saving Opt-in and Opt-out information within a mock database that if needed, can be accessed at a later time.  This example was accomplished using C# in a .Net environment along with a previously created Excel 2013 spreadsheet.  This application can be used with the following code used for this example:

 1. Set Up Excel/WSDL Reference

The first thing you will want to do to set up this application is to reference our WSDL ( as a service reference to your project. This option can be found by right clicking References in the solution Explorer.  After this to have the ability
to edit/write to your excel document we used The Microsoft Excel 15.0 Object Library.  This can be found in by adding a COM reference under the same References option in the Solution Explorer.  Here is what your first few lines of code should look like:

2. Set Up the Variables

Next we need to set up the variables that are going to be used in our code behind of the URL. This will be accomplished within your post back page (this is a live url that you set up yourself or with a host company). This portion of code goes in our code behind of the URL.  The “code behind” is where the functionality of your webpage lies.  This is accomplished with the following code:

This code has the list of the values for the post back you will receive from CDYNE when someone responds to an SMS.   You can get more information on the different responses here.  In this example we will be using the FromPhoneNumber, Message (only grabbing “Opt in” and “Opt out”), and ResponseReceiveDate.

3. Grab the Opt-In Messages and Save to Excel

After this we will code out the portion needed to only grab the “Opt in” messages and save them to our excel document.  The portion of code is below.  Please note the loops used to cycle through the Excel spreadsheet so that no information is replaced or duplicated:

4. Grab the Opt-Out Messages and Save to Excel

The next portion is exactly like the “Opt in” portion of code.  The only difference is that it is an else if and it is to grab “Opt out”:

This example shows you how to save only opt-ins and opt-outs for SMS messaging handling with your clients.  Using Excel 2013 we were able to save the data to a spreadsheet only if the messages were “Opt in” and “Opt out”.  With a little change to the above code, you could choose to save this or different data from incoming SMS to your DID/Short Code.  More information on SMS Notify click here and for development help please check out our wiki.

Leave a reply