Hi,
I want to send notification message to recipient after adding recipient details in database. No compilation error but program crash once i click menu. When I check the database, the data was adding successfully but crash while passing data for sending message.
Code:
void CSMSExampleAddressContainer::CreateRecordL(TDesC& aName, TDesC& aPhone, TDesC& aKey)
{
iContactName = aName;
iContactNumber = aPhone;
iContactPK = aKey;
iEngine->SetName( iContactName );
iEngine->SetPublicKey( iContactPK );
iEngine->SetPhone( iContactNumber );
// Now create the record
iEngine->AddRecordL();
// Send notofication message
SendNotificationL(iContactName, iContactNumber);
}
void CSMSExampleAddressContainer::SendNotificationL(TDesC& aName, TDesC& aPhone)
{
iContactName = aName;
iContactNumber = aPhone;
_LIT( KBreaks, "\n" );
TBuf <100> bufMessage;
bufMessage.Append(iContactName); // Contact name
bufMessage.Append(KNotifyMes0); // is sending handshake. Do you want to accept?
bufMessage.Append(KBreaks);
bufMessage.Append(KNotifyMes1); // 0 No
bufMessage.Append(KBreaks);
bufMessage.Append(KNotifyMes2); // 1 Yes
bufMessage.Append(KBreaks);
bufMessage.Append(KNotifyMes3); // Reply?
iSMSEngine->CreateAndSendMessage(iContactNumber, bufMessage);
}
****
Code:
void CSMSExampleAppUi::CreateAndSendMessage(const TDesC& aAdd, const TDesC& aSms)
{
// Create a new SMS to outbox
iAddress = aAdd;
iMessage = aSms;
iEngine->CreateSMSMessageL( iAddress, iMessage );
// Validate it before sending
if ( iEngine->ValidateCreatedSMS() )
{
iEngine->SendSMSL(); // Now send
}
else
{
NotifyMessageInvalidL(KInvalidMessageResend); // Showing error notes
}
}
Anybody have any idea... what's wrong with the code?
Thanks...