| ID | CS001307 | Creation date | February 16, 2009 |
| Platform | S60 3rd Edition; S60 3rd Edition, FP1; S60 3rd Edition, FP2; S60 5th Edition | Tested on devices | Nokia 6220 Classic |
| Category | Symbian C++ | Subcategory | Messaging, SMS |
| Keywords (APIs, classes, methods, functions): RSendAs, RSendAsMessage, RSendAs::Connect(), RSendAsMessage::CreateL(), RSendAsMessage::AddRecipientL(), RSendAsMessage::SetBodyTextL(), RSendAsMessage::SendMessageAndCloseL() |
This code snippet demonstrates how to send an SMS using RSendAs and RSendAsMessage.
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.
private: // New methods
void SendSMSL();
#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);
}
The application sends an SMS to the number specified in the code.
No related wiki articles found