Hi all,
I want to create a new email and save it into a user defined MailBox. I can able to create and save this email into Inbox, Draft and Sent folder but I cant able to add it into MailBox. I am using following code for creating and saving a email into MailBox but I am getting MSGS 294 panic at line TRAPD(err2,entry->CreateL(newEntry));
The code I am using is below,........
CreateNewEmailL(TMsvId aFolderIdToSave)
{
CMsvSession* msvSession = CMsvSession::OpenSyncL( *this );
CleanupStack::PushL(msvSession);
CClientMtmRegistry* iMtmReg = CClientMtmRegistry::NewL( *msvSession );
CSmtpClientMtm* smtpMtm = static_cast<CSmtpClientMtm*>(iMtmReg->NewMtmL(KUidMsgTypeSMTP));
CleanupStack::PushL(smtpMtm);
TMsvSelectionOrdering ordering;
ordering.SetShowInvisibleEntries(ETrue);// SMTP services are invisible
ordering.SetGroupByMtm(ETrue);
CMsvEntry* entry = CMsvEntry::NewL(*msvSession, KMsvRootIndexEntryId, ordering );
CleanupStack::PushL(entry);
CMsvEntrySelection* rootChildren = entry->ChildrenWithMtmL(KUidMsgTypeSMTP);
CleanupStack::PushL(rootChildren);
if (rootChildren->Count() == 0)
// Can't find any SMTP services
User::Leave(KErrNotFound);
TMsvEntry newEntry;
newEntry.iServiceId = (*rootChildren)[0];// Set the service ID to the first SMTP service
CleanupStack::PopAndDestroy(rootChildren);
newEntry.iMtm = KUidMsgTypeSMTP;
newEntry.iType = KUidMsvMessageEntry;
_LIT(KOutGoingMsgText, "Outgoing message");
newEntry.iDescription.Set(KOutGoingMsgText);
newEntry.SetReadOnly(EFalse);
newEntry.SetVisible(ETrue);
newEntry.SetInPreparation(EFalse);
TRAPD(err1,entry->SetEntryL(aFolderIdToSave));
// Create the new message in the context of 'entry' (Outbox)
TRAPD(err2,entry->CreateL(newEntry));
// Push entry onto cleanup stack, so if we leave from here on
// it will be deleted from the message server (don't want half-created messages
// hanging around)
TRAPD(err3,msvSession->CleanupEntryPushL(newEntry.Id()));
smtpMtm->SwitchCurrentEntryL(newEntry.Id());
smtpMtm->AddAddresseeL(_L("me@net.com"));
smtpMtm->SetSubjectL(_L("Subject"));
smtpMtm->Body().InsertL(0, _L("Message body"));
smtpMtm->SaveMessageL();
msvSession->CleanupEntryPop();
CleanupStack::PopAndDestroy(entry);
CleanupStack::PopAndDestroy(smtpMtm);
CleanupStack::PopAndDestroy(msvSession);
}
where in I am passing the TMsvId of the respective mailbox present.
Can anyone give me any pointer that where I am making mistake?
waiting for your valuable reply's........
Thanks in advance
Bharat



