Skip to content

Instantly share code, notes, and snippets.

@dio
Created April 13, 2011 15:53
Show Gist options
  • Select an option

  • Save dio/917807 to your computer and use it in GitHub Desktop.

Select an option

Save dio/917807 to your computer and use it in GitHub Desktop.
void XQMessaging::CreateAndSendMessageL( int aType, TBool aEmbedded, QString aSubject, QStringList aAddressList, QString aBody ){
TUid serviceUid;
if (aType == 1)
serviceUid = KSenduiMtmSmsUid;
else if (aType == 2)
serviceUid = KSenduiMtmSmtpUid;
CMessageData* message = CMessageData::NewLC();
if (aSubject.length() != 0){
TBufC<256> subject(aSubject.utf16());
message->SetSubjectL(&subject);
}
for (TInt i=0; i<aAddressList.length(); i++) {
if (aAddressList.at(i).length() != 0) {
TBufC<256> address(aAddressList.at(i).utf16());
message->AppendToAddressL(address);
}
}
CRichText* richText;
CParaFormatLayer* paraFormatLayer;
CCharFormatLayer* charFormatLayer;
paraFormatLayer=CParaFormatLayer::NewL();
charFormatLayer=CCharFormatLayer::NewL();
CleanupStack::PushL(paraFormatLayer);
CleanupStack::PushL(charFormatLayer);
TRAPD(err, richText = CRichText::NewL(paraFormatLayer, charFormatLayer))
if (err == KErrNone) {
if (aBody.length() != 0) {
HBufC * buf = HBufC::NewLC(aBody.length());
buf->Des().Copy(aBody.utf16());
richText->InsertL(0, buf->Des());
message->SetBodyTextL(richText);
CleanupStack::PopAndDestroy(buf);
}
}
else {
// handle error and return
CleanupStack::PopAndDestroy(3);
return;
}
if (iSendUi) {
// start message editor through SendUI
iSendUi->CreateAndSendMessageL( serviceUid, message, KNullUid, aEmbedded );
}
delete richText;
CleanupStack::PopAndDestroy( 3 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment