×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    63

    Help needed in reading email from inbox

    I am trying to read email from the phone Inbox. HasStoreL() always returns false. Please help. The same code was working sometime back but i made lot of changes and i am not able to figure out why it is not working now. Sorry for posting lengthy code.

    msvEntry->Count() function returns the correct number of emails in the inbox. But i am not able to read subject, from and email body.

    void CReadEmail::ReadEmailL(TDesC& aMailBoxType,TDesC &aMailBoxName)
    _LIT(KPopType,"pop");
    iSession = CMsvSession::OpenSyncL(*this);

    CEmailAccounts* emailAccount = CEmailAccounts::NewLC();
    TPtrC ptr(aMailBoxType);
    CMsvEntry* msvEntry;
    if(!ptr.Compare(KPopType))
    {
    RArray<TPopAccount> pop3Accounts;
    emailAccount->GetPopAccountsL(pop3Accounts);
    RBuf PopMailboxName;
    TMsvId PopMailboxId;
    for(TInt index=0;index<pop3Accounts.Count();index++)
    {
    PopMailboxName.CreateL(pop3Accounts[index].iPopAccountName);
    if(!PopMailboxName.Compare(aMailBoxName))
    {
    PopMailboxId = pop3Accounts[index].iPopService;
    }
    }
    pop3Accounts.Reset();
    PopMailboxName.Close();
    msvEntry =CMsvEntry::NewL(*iSession,PopMailboxId,TMsvSelectionOrdering::TMsvSelectionOrdering());
    }
    else
    {
    RArray<TImapAccount> imap4Accounts;
    emailAccount ->GetImapAccountsL(imap4Accounts);
    RBuf ImapMailboxName;
    TMsvId ImapMailboxId;
    for(TInt index=0;index<imap4Accounts.Count();index++)
    {
    ImapMailboxName.CreateL(imap4Accounts[index].iImapAccountName);
    if(ImapMailboxName.Compare(aMailBoxName))
    {
    ImapMailboxId = imap4Accounts[index].iImapService;
    }
    }
    imap4Accounts.Reset();
    ImapMailboxName.Close();
    msvEntry =CMsvEntry::NewL(*iSession,ImapMailboxId,TMsvSelectionOrdering::TMsvSelectionOrdering());
    CleanupStack::PushL(msvEntry);
    }

    CleanupStack::PopAndDestroy(emailAccount);


    if(msvEntry->Count())
    {
    TMsvSelectionOrdering sort;
    sort.SetShowInvisibleEntries(ETrue);
    sort.SetSorting(EMsvSortByDateReverse);
    msvEntry->SetSortTypeL(sort);

    CMsvEntrySelection* msvEntrySelection = msvEntry->ChildrenL();

    for(TInt index =0; index<msvEntrySelection->Count();index++)
    {
    TMsvId emailId = msvEntry->ChildDataL(msvEntrySelection->At(index)).Id();
    CMsvEntry* entry = iSession->GetEntryL((*msvEntrySelection)[index]);
    CleanupStack::PushL(entry);

    if(entry->HasStoreL())
    {
    CMsvStore* store=entry->ReadStoreL();
    CleanupStack::PushL(store);
    CImHeader* header=CImHeader::NewLC();
    header->RestoreL(*store);
    TBuf<50> subject = header->Subject();
    TBuf<50> from = header->From();
    CleanupStack::PopAndDestroy(header);
    CleanupStack::PopAndDestroy(store);
    }

    CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL();
    CCharFormatLayer* charFormatLayer=CCharFormatLayer::NewL();
    CRichText* richText=CRichText::NewL(paraFormatLayer,charFormatLayer);
    CImEmailMessage* emailMessage = CImEmailMessage::NewLC(*entry);
    emailMessage->GetBodyTextL(emailId,CImEmailMessage::EThisMessageOnly,*richText,*paraFormatLayer,*charFormatLayer);
    RBuf emailBody;
    TInt in = richText->DocumentLength();
    emailBody.CreateL(richText->DocumentLength());
    emailBody.Zero();
    richText->Extract(emailBody);

    const TInt length = richText->DocumentLength();
    TBuf<400> mailContent;
    mailContent.Copy(richText->Read(0,length));

    emailBody.Close();
    CleanupStack::PopAndDestroy(emailMessage);
    delete richText; richText=NULL;
    delete charFormatLayer; charFormatLayer=NULL;
    delete paraFormatLayer; paraFormatLayer=NULL;
    CleanupStack::PopAndDestroy(entry);
    }
    }

  2. #2
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    63

    Re: Help needed in reading email from inbox

    wizard_hu where are you ? Please help ...

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

    Re: Help needed in reading email from inbox

    You can find a very similar issue here: http://discussion.forum.nokia.com/fo...d.php?t=170698
    Just it is about Bluetooth. Unfortunately I do not really know what happens, and if Wiso33 succeeded or not after all.

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: Help needed in reading email from inbox

    I think the last comment is about checking that you are accessing right children, so make sure you go deep enough with the childres stuff..

  5. #5
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    63

    Re: Help needed in reading email from inbox

    Can you please explain how to get deep and find the right children ?

    Thanks champions

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,683

    Re: Help needed in reading email from inbox

    If the issue is really about children, you should simply get them via CMsvEntry::ChildrenL, and check what they are.

  7. #7
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    63

    Re: Help needed in reading email from inbox

    Thanks all for your Help. After struggling for two full days i found why HasStoreL() returns false and ReadStoreL() leaves

    Default retrieval settings will retrieve only headers and and not email body. So if i manually retrieve the email it works !!!

    I think i need to use GetMailL() from CImPOP3GetMail class to retrieve the email body from server. Is that correct ?

    I am not an expert in messaging hence my above understanding could be wrong.

Similar Threads

  1. Replies: 1
    Last Post: 2009-03-03, 15:11
  2. Problem while reading message from inbox
    By ash_leo in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2008-12-26, 14:01
  3. Checking for new email
    By smileyyhl in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2008-06-12, 09:03
  4. Replies: 0
    Last Post: 2005-07-27, 12:03
  5. How to send complete email settings?
    By kick121 in forum Smart Messaging
    Replies: 2
    Last Post: 2003-02-26, 05:48

Posting Permissions

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