Archived:Sending an SMS using Symbian C++
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Article Metadata
Code Example
Tested with
Devices(s): Nokia 6220 Classic
Compatibility
Platform(s): S60 3rd Edition; S60 3rd Edition, FP1; S60 3rd Edition, FP2; S60 5th Edition
Article
Keywords: RSendAs, RSendAsMessage, RSendAs::Connect(), RSendAsMessage::CreateL(), RSendAsMessage::AddRecipientL(), RSendAsMessage::SetBodyTextL(), RSendAsMessage::SendMessageAndCloseL()
Created: tapla
(13 Feb 2009)
Last edited: hamishwillee
(02 Jul 2012)
Contents |
Overview
This code snippet demonstrates how to send an SMS using RSendAs and RSendAsMessage.
MMP file
The following library is required:
LIBRARY sendas2.lib
You may also want to add the following capability:
CAPABILITY NetworkServices
The capability is not required but without it the application asks for permission to send the message.
Header file
private: // New methods
void SendSMSL();
Source file
#include <rsendas.h>
#include <rsendasmessage.h>
#include <smut.h>
void CAppUi::SendSMSL()
{
RSendAs sendAs;
TInt err = sendAs.Connect();
if (err) {
// TODO: Error handling
return;
}
CleanupClosePushL(sendAs);
RSendAsMessage sendAsMessage;
sendAsMessage.CreateL(sendAs, KUidMsgTypeSMS);
CleanupClosePushL(sendAsMessage);
// Add the receiver
_LIT(KReceiver, "+358123123123");
sendAsMessage.AddRecipientL(KReceiver, RSendAsMessage::ESendAsRecipientTo);
// Set the body text
_LIT(KBodyText, "Hello!");
sendAsMessage.SetBodyTextL(KBodyText);
// Send the message
sendAsMessage.SendMessageAndCloseL();
CleanupStack::Pop(); // sendAsMessage (already closed)
CleanupStack::PopAndDestroy(); // sendAs
_LIT(KInfoText, "Message sent.");
iAppView->LogPrintL(KInfoText);
}
Postconditions
The application sends an SMS to the number specified in the code.
Supplementary material
- You can test SMS sending features in action in a simple, executable application into which this code snippet has been patched. The application is available for download at Media:ExampleStub w SMS sending.zip
- You can examine all the changes that are required to implement SMS sending in an application. The changes are provided in unified diff and colour-coded diff formats: Media:Sending an SMS.diff.zip
- For general information on applying the patch, see Using Diffs.
- For unpatched stub applications, see Example stub.


The article has lucidly explained the way to send an SMS in Sybian C++. The code for the application includes all the information regarding to the library files, Capabilities and header files to included. The mannar in which code for the application is represente is very simple to understand fo a beginner.
Though the application given in this article is a basic application for sending an SMS to the specified number, it makes us aware of the basic messaging process. The article is specially meant for beginners. Beginners can use this article for their further progress.
--deepikagohil 02:06, 8 September 2009 (UTC)