CE 6.0 – Sending an SMS Message.

CE 6.0 introduced a number of new and interesting technologies, this includes the Vista Network Projector (I will record a demo of this working shortly), CellCore support, and more.

CellCore gives you the ability to send SMS Messages programmatically from your application without user interaction, ideal for those Machine to Machine applications, you can of course also dial up to the Internet and then connect to XML Web Services (more on hosting XML Web Services on CE 6.0 coming shortly).

But how do you send an SMS Message through the CellCore APIs ? – The neat thing about CellCore is that it abstracts you, the developer from the underlying cell hardware in much the same way as the display driver abstracts you from the underlying display hardware.

So, how do you programmatically send an SMS message ? – Here’s some C/C++/Win32 code that shows you how to do this.


// SendMessage.cpp : Defines the entry point for the application.

#include “stdafx.h”
#include <sms.h>

void SendSMS(BOOL bSendConfirmation,
BOOL bUseDefaultSMSC,
LPCTSTR lpszRecipient,
LPCTSTR lpszMessage);

int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
SendSMS(FALSE,TRUE,L“”,L“+14258828080”,L“Hello SMS Message from CE 6.0!”);
return 0;

void SendSMS(BOOL bSendConfirmation,
BOOL bUseDefaultSMSC,
LPCTSTR lpszRecipient,
LPCTSTR lpszMessage)
SMS_HANDLE smshHandle;
SMS_ADDRESS smsaDestination;
SMS_MESSAGE_ID smsmidMessageID = 0;
TCHAR tcBuffer[1024];

StringCchCopy(tcBuffer, 1024, lpszMessage);

// try to open an SMS Handle
if (hr != ERROR_SUCCESS) {
printf (“SmsOpen fail %x %d”, hr, GetLastError());
// Create the destination address
memset (&smsaDestination, 0, sizeof (smsaDestination));
smsaDestination.smsatAddressType = SMSAT_INTERNATIONAL;
lstrcpy(smsaDestination.ptsAddress, lpszRecipient);

// Set up provider specific data
tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE;
tpsd.psMessageClass = PS_MESSAGE_CLASS1;
tpsd.psReplaceOption = PSRO_NONE;

// Send the message, indicating success or failure
hr = SmsSendMessage (smshHandle, NULL, &smsaDestination, NULL,
(PBYTE) tcBuffer, (lstrlen(tcBuffer)+1)*sizeof(TCHAR),
if (hr == ERROR_SUCCESS)
MessageBox(NULL,L“Message sent”,L“SMS Test”,MB_OK);
SmsClose (smshHandle);

Note that in this sample the destination number being used is the Microsoft  switchboard, so don’t try sending your SMS messages there!

The sample code above also needs to link with SMS.LIB otherwise the code won’t build – it would be a simple task to make this into a Win32 DLL which could then be called from a managed application.

I have the sample working on an ICOP eBox 2300 with an Enfora GSM radio device – note that adding the CellCore components from the catalog isn’t enough to get the Enfora device working, the Enfora drivers only ship with the CEPC and Emulator BSPs (I think ICOP have also added the Enfora drivers to their BSP), so you will need to copy the Enfora driver files from the CEPC/Emulator BSP to your BSP tree (you can find the enfora drivers here – C:\WINCE600\PLATFORM\CEPC\SRC\DRIVERS\RILPDD) – you will also need to set an environment variable IMGENFORA=1.

– Mike 

Comments (3)

  1. Shankar says:

    Hi Mike,

       Thanks for the application, i would like to know wheather the same application will work on windows mobile 5.0. Is there any modification required?



  2. Brian says:

    Hey Mike,

    Thanks for the example code.

    Unfortunately, it won’t link for me.

    I am using the ARMV4I platform.

    I added the following additional library directory to the Linker Input property: C:WINCE600PUBLICCELLCOREOAKLIBARMV4IDEBUG

    As a newb, I am struggling to make this work, even with the documentation out there.  Please lend a hand- anyone.  Thanks!


  3. Brian says:

    Please disregard my previous post.

    My CE image didn’t have Cellcore.

    Added Cellcore catalog items, rebuilt CE image, regenerated SDK, uninstalled previous SDK, installed new SDK, recompiled example app, success.