Visual Basic
Web Scripting

Active Server Pages

Mailing List
Receive free code snippets and notices when this site is updated.


Introduction to Txtlets

Today many people carry a mobile phone. Most of which now support SMS (Small Message Service). SMS allows short messages of 160 characters to be sent between phones. Given that some people don’t own PCs or have Internet access SMS can be an ideal way to provide applications.

Txtlets make writing SMS pull applications easy. A pull application is one where a user requests that your application do something by sending a text message from their mobile phone.

To write txtlets you need: -

  • Microsoft .NET SDK
  • Flipmind Txtlet Server
  • A Nokia Mobile Phone with data cable to connect to your PC

In this tutorial I will show you how to create a Txtlet using C#.

The ITxtlet interface

A txtlet is created by implementing the ITxtlet interface.

A txtlet has three method: -

  • Init
    Called when the Txtlet is first loaded.
  • Service
    Called on each request
  • Destroy
    Called just before the txtlet is removed from memory

Txtlets are thread safe. Each request to a txtlet runs in it’s own thread.

A Simple Txtlet

Now we will write a simple txtlet that tells the time via SMS. GenericTxtlet implements the other methods of ITxtlet that we are not interested in for this example.

using System;
using TxtletServer.Txtlet;
using TxtletServer.Messaging;

namespace TxtletExamples {
  public class TimeTxtlet : GenericTxtlet {
    public override void Service( TxtletRequest request, TxtletResponse response ) {
      string txt;
      txt = "The time is " + DateTime.Now.ToShortTimeString();
      TextMessage msg = new TextMessage( request.Message.Source, txt);
      response.Send ( msg );

Compiling the Txtlet

Execute the following from the command line to compile the txtlet

csc /t:library /out:timetxtlet.dll /r:System.dll,txtletserver.dll timetxtlet.cs

Configuring the Time Txtlet

In order to access a txtlet you need to: -

  • Place the compiled timetxtlet.dll somewhere dot net can load it from
  • Add a txtlet entry to txtlet.xml
  • Add a txtlet-mapping to txtlet.xml

Txtlet Entry

Add this to the <txtlets> section of txtlet.xml

<txtlet name="timeTxtlet" class="TxtletExamples.TimeTxtlet,timetxtlet">
<description>Returns the current time</description>

Txtlet Mapping

Many txtlets can be running at time on a Txtlet Server. Txtlets mappings are how it knows how to direct requests to a txtlet.

SMS requests can be directed based on their destination phone number and the content of the message.

For example the following txtlet would map any request with the text “TIME” to your TimeTxtlet. Mappings can be regular expressions.

<txtlet-mapping name="timeTxtlet">

The first txtlet that matches is used to service the request.

Trying it out

To try out your txtlet you will need to get a copy of Txtlet Server and the Nokia PC Connectivity SDK 3.0 from

  • Install the Nokia PC Connectivity SDK and plug in your mobile phone to the data cable
  • Install the Txtlet Server
  • Start the Txtlet server by typing
    starttxtletserver from the command line

From another phone send an SMS to the number of the phone connected to the PC.


Phone Number: 22323234

The SMS:

“The time is xx:xx”

should be returned to you via SMS.

Next Time

In my next article I will be discussing some of the more advanced txtlet implementations that are included with Txtlet Server.


The makers of Txtlet Server

Nokia Forum
Information on nokia phones that support data cables

Microsoft .NET Framework Software Development Kit