×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    260

    How should I create email into MailBox?.... MSGS 294

    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

  2. #2
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    260

    Re: How should I create email into MailBox?.... MSGS 294

    Hi all,

    That panic shows I have to call asynchronous version of the method CreateL()
    so I called that asynchronous version as shown below but still problem exists at line smtpMtm->SwitchCurrentEntryL(newEntry.Id());
    now it is popping error -1 which emplies that object not found.


    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)

    CMsvOperationActiveSchedulerWait * iWaitOp = CMsvOperationActiveSchedulerWait::NewLC();;
    CleanupStack::Pop(iWaitOp);
    CMsvOperation* pCreateFolderOp = entry->CreateL(newEntry,iWaitOp->iStatus);
    // 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)
    CleanupStack::PushL(pCreateFolderOp);
    iWaitOp->iStatus = KRequestPending;
    iWaitOp->Start();
    CleanupStack::PopAndDestroy(pCreateFolderOp);
    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);
    }

    Can anyone knows why this error is popped?
    any pointer in this regard is highly appreciated.

    regards,
    bharat

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How should I create email into MailBox?.... MSGS 294

    Though I do not know the solution, two things to note:
    - you should not set "iWaitOp->iStatus" manually, it is the task of the service-provider (CMsvEntry::CreateL in this case)
    - but you should check "iWaitOp->iStatus" after the wait loop has completed - since it is absolutely not sure that the message has been created successfully. KErrNotFound a few lines later indicates that "iWaitOp->iStatus" is probably not KErrNone...

    In fact iWaitOp is not a member variable, it should not be "i".

  4. #4
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    260

    Re: How should I create email into MailBox?.... MSGS 294

    Hi,

    Thanks for your reply,
    In fact I did that also i mean I checked iStatus after operation complete and that status shows error code -5 means KErrNotSupported -5 The operation requested is not supported

    So is it sure that we cant able to add an email entry into MailBox?

    regards,
    Bharat

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How should I create email into MailBox?.... MSGS 294

    Unfortunately I do not know where a new e-mails are supposed to be created. However when I create SMS-s, I create them via the MTM's CreateMessageL (#1 thing to try), and create them in the Draft folder (#2 thing you can try, however I can easily imagine that e-mails have to be created under some e-mail folder entry).

  6. #6
    Regular Contributor
    Join Date
    Nov 2006
    Posts
    260

    Re: How should I create email into MailBox?.... MSGS 294

    Hi,

    I have also tried with the same but got same error -5
    and 2nd thing I tried before that adding this email entry into draft folder and succeed into that. But i want to add the email entry into MailBox.

    regards,
    bharat

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How should I create email into MailBox?.... MSGS 294

    And what about creating the entry where you actually can, and moving it later to the preferred location?

Similar Threads

  1. Replies: 9
    Last Post: 2004-09-12, 10:08
  2. Is it possible to create a Mailbox programmaticaly?
    By asangamneheri in forum Symbian
    Replies: 4
    Last Post: 2004-08-06, 15:01
  3. Sending Email over GPRS
    By pankajmahto in forum Symbian
    Replies: 0
    Last Post: 2004-07-29, 07:48
  4. email mtm help is needed
    By siemensc55 in forum Symbian
    Replies: 0
    Last Post: 2004-07-18, 18:58
  5. Create Mailbox
    By WinHw in forum Symbian
    Replies: 0
    Last Post: 2003-06-18, 09:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×