×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Jun 2003
    Location
    Jakarta, Indonesia
    Posts
    164

    Reading email attachment

    Hi all, I'm trying to read the attachments both from inbox/send and stuck with that.

    I already succeed to retrieve all other info (from, cc, bcc, subject, body, etc) and also succeed to read the MMS attachment, but when try to read the email attachment the attachment count always return 0.

    Here is my code :

    MMsvAttachmentManager& manager = store->AttachmentManagerL();
    TInt count=manager.AttachmentCount();
    //Where store is CMsvStore object
    //This work with MMS but not with email

    MMsvAttachmentManager& manager = emailMessage->AttachmentManager();
    TInt count=manager.AttachmentCount();
    //Where emailMessage is CImEmailMessage object
    //This also not work for email, always return 0

    Any suggestion?

    Best regards,



    WinHw

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: Reading email attachment

    Wiki has good examples and it is good idea to start searching on Wiki first.

    See this: How to retrieve e-mail contents

    Then this: How to get the attachments from an EMail
    Nokia Developer Wiki Moderation team

  3. #3
    Regular Contributor
    Join Date
    Jun 2003
    Location
    Jakarta, Indonesia
    Posts
    164

    Re: Reading email attachment

    My code is exactly the same as in the wiki, already check it before i'm posting, and as I wrote in my previous post, it always return 0 attachment. Anyone have tried this and succeed?


    Regards,



    WinHw

  4. #4
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    81

    Smile Re: Reading email attachment

    Hi WinHw,
    I did read ur post today, it was really good for all, but there is not showing how u did read email body, etc.
    I am trying to overcome from this from for last two months.
    Please guide me how can i read mail body contents.
    thanks
    regards Rajat

  5. #5
    Regular Contributor
    Join Date
    Jun 2003
    Location
    Jakarta, Indonesia
    Posts
    164

    Re: Reading email attachment

    Hi, hope this can help you...

    First, get all mailbox account available :
    CEmailAccounts* emailAccount = CEmailAccounts::NewLC();

    // this one to get POP3 maiblox
    RArray<TPopAccount> pop3Accounts;
    emailAccount->GetPopAccountsL(pop3Accounts);
    //Loop as you wish until pop3Accounts.Count()
    //This one get the mailbox id and name
    TMsvId mailboxId = pop3Accounts[index].iPopService;
    RBuf mailboxName;
    mailboxName.CreateL(pop3Accounts[index].iPopAccountName);
    pop3Accounts.Reset();

    // this one to get IMAP4 maiblox
    RArray<TImapAccount> imap4Accounts;
    emailAccount ->GetImapAccountsL(imap4Accounts);
    //Loop as you wish until pop3Accounts.Count()
    //This one get the mailbox id and name
    TMsvId mailboxId = imap4Accounts[index].iImapService;
    RBuf mailboxName;
    mailboxName.CreateL(imap4Accounts[index].iImapAccountName);
    imap4Accounts.Reset();

    //Cleanup
    mailboxName.Close();
    CleanupStack::PopAndDestroy(emailAccount);

    Then... we need the mailboxId to open the specified mailbox folder
    CMsvEntry* msvEntry = iMsvSession->GetEntryL(mailboxId);
    //if the mailbox is not empty
    if(msvEntry->Count())
    {
    //sort the content of the mailbox folder by date
    TMsvSelectionOrdering sort;
    sort.SetShowInvisibleEntries(ETrue);
    sort.SetSorting(EMsvSortByDateReverse);
    msvEntry->SetSortTypeL(sort);
    CMsvEntrySelection msvEntrySelection = msvEntry->ChildrenL();
    //Loop until msvEntry->Count()
    //the real email id
    TMsvId emailId = msvEntry->ChildDataL(msvEntrySelection->At(index)).Id();

    CMsvEntry* entry = iMsvSession->GetEntryL((*msvEntrySelection)[index]);
    CleanupStack::PushL(entry); //this is the entry to the e-mail
    //Check if the entry has store
    if(entry->HasStoreL())
    {
    CMsvStore* store=entry->ReadStoreL();
    CleanupStack::PushL(store);

    //email header
    CImHeader* header=CImHeader::NewLC();
    header->RestoreL(*store);
    //We already get the email header, check CImHeader class refrence to get the header contents
    s 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;
    emailBody.CreateL(richText->DocumentLength());
    emailBody.Zero();
    richText->Extract(emailBody);

    //Yes... finally we get the email body

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


    Regards,



    WinHw

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    6

    Re: Reading email attachment

    Hi WinHw.
    I'm facing the same problem. I want to retrieve an attachment from email message. Problem solved? If so - please give me an example. Thnx

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

    Re: Reading email attachment

    If someone is still looking out for answer.

    Check the attachment count after this line.

    CImEmailMessage* emailMessage = CImEmailMessage::NewLC(*entry);

    Hope it helps.

Similar Threads

  1. POP3 email attachment retrieval
    By augustis in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2008-07-25, 13:28
  2. Problem with creating email attachment
    By V_Nemkov in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-11-01, 06:33
  3. Reading E-mail attachment
    By yddusane in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-01-24, 08:06
  4. Replies: 0
    Last Post: 2006-02-07, 14:59
  5. open email attachment in Series60?
    By bcchong in forum Symbian
    Replies: 0
    Last Post: 2002-07-09, 00:11

Posting Permissions

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