I am trying to send an sms immediately after construction from a 7650 device, but it won't work.
I am using the CSendAs class to create a message in the outbox. This sort of works, at least it is visible in the 7650's messaging application, with seemingly correct details.
Then, inspired by the GDSMS example, I try to issue an asynchronous call to schedule the message and pass the request status member of a CMsvOperationWait as argument.
What happens is that I get a panic/error message popup saying something like "Message could not be sent" as well as a "System error" message.
So, is it a correct approach to use the above scheme for immediate sending ?
I have not found documentation on the CMsvOperationWait, is it a beta-glitch or is it deprecated and unsupported ?
Am I missing something in the creation of the message which makes it unsendable ?
Is there any documentation other than the API reference that I should read to understand this better ?
Code snippet follows:
// Create SendAs
sendAs = CSendAs::NewL(*this);
// Set SMS MTM
smsUid.iUid = KUidMsgTypeSMS;
sendAs->SetMtmL( smsUid );
// Check services
if( sendAs->AvailableServices().Count() < 1 )
// ------ Issuing a SetService(1) results in out of range panic
// Check Capabilities of the SMS MTM
User::LeaveIfError( sendAs->QueryMessageCapability (KUidMtmQueryCanSendMsg, EFalse));
User::LeaveIfError( sendAs->QueryMessageCapability(KUidMtmQueryMaxBodySize, ETrue));
// Create the Message in the outbox
sendAs->CreateMessageL( KMsvGlobalOutBoxIndexEntryId );
// Set recipient
sendAs->AddRecipientL(iTelephoneNumber); // A literal with a telephonenumber
iMessageBody->InsertL(0, aMessage );
// Set body of message
User::LeaveIfError( r = sendAs->ValidateMessage());
// Save message to message server, and make it visible in outbox
sendAs->SaveMessageL( ETrue );
// Schedule to send now.
// Use MTM from sendAs
CBaseMtm* SmsMtm = &(sendAs->ClientMtm());
entry.SetOffPeak(EFalse); // What does this do ?
entry.SetSendingState(KMsvSendStateWaiting); // Is this necessary ?
CMsvEntrySelection* sel = new(ELeave) CMsvEntrySelection;
CMsvOperation* operation = NULL;
CMsvOperationWait* waiter = CMsvOperationWait::NewLC();
operation = SmsMtm->InvokeAsyncFunctionL( ESmsMtmCommandScheduleCopy, *sel, dummy, waiter->iStatus );
CleanupStack::PopAndDestroy(4); // sendAs, sel, operation, waiter
sendAs = NULL;