void CMessageSend_S60::CreateMMSL
(
TDesC16& aBodyText,
TDesC16& aSubject,
TDesC16& aAttachedFilename,
TDesC16& aPhonenum
)
{
// - CMsvEntry accesses and acts upon a particular Message Server entry.
// - NewL() does not create a new entry, but simply a new object to access an existing entry.
// - It takes in as parameters the client's message server session,
// ID of the entry to access and initial sorting order of the children of the entry.
CMsvEntry* theEntry = CMsvEntry::NewL
(
*iSession,
KMsvGlobalOutBoxIndexEntryId,
TMsvSelectionOrdering()
);
CleanupStack::PushL( theEntry );
// Set context to the parent folder (Outbox)
iMmsMtm->SwitchCurrentEntryL( theEntry->EntryId() );
// Create new message in the parent folder (Outbox) and set it as the current context.
iMmsMtm->CreateMessageL( iMmsMtm->DefaultServiceL() );
CleanupStack::PopAndDestroy(); // entry
// Set recipients
// use this to add the "To" recipients.
iMmsMtm->AddAddresseeL( aPhonenum );
// Set message subject
//iMmsMtm->SetSubjectL( aSubject );
iMmsMtm->SetSubjectL( aBodyText );
// Doesn't work, don't know why, so insert bodytext as attachment file
// Set body text
CRichText& richBodyText = iMmsMtm->Body();
richBodyText.Reset();
richBodyText.InsertL( KBodyTextStartPosition, aBodyText );
// Set attchment file, including image file
TRAP( err, SetAttachmentToMsgL( aAttachedFilename ) );
if( err != KErrNone )
{
User::Leave( err );
}
TMsvEntry theTMsvEntry = iMmsMtm->Entry().Entry();
// Set InPreparation to false
theTMsvEntry.SetInPreparation(EFalse);
// Mark as visible, after this the message can be seen in Outbox and,
// after sending, in Sent folder.
theTMsvEntry.SetVisible(ETrue);
// Commit changes
iMmsMtm->Entry().ChangeL(theTMsvEntry);
//Save the changes
iMmsMtm->SaveMessageL();
// Send Message
SendMessageL();
}