Storing Downloaded Email Messages

This tutorial explains how to store incoming email messages.

Introduction

You can store and restore the incoming email message using the TDesC8 or TDesC16 function. Ensure that you follow these guidelines while using these functions:

  • If you want to store the downloaded email message data as 16 bit, then storing is slow as the downloaded message in 8 bit should be converted to 16 bit before it is stored. However, reading and displaying is fast as the email message data is in 16 bit.

  • If you want to store the downloaded email message data as 8-bit, then reading and displaying it is slow as the 8 bit email message data should be converted to 16 bit before it is displayed. However, storing is fast.

Procedure

  1. For the MTM to use CMsvPlainBodyText for storing downloaded email messages, get the CMsvPlainBodyText object using the InitialisePlainBodyTextForWriteL() method of CMsvStore.

  2. Set CMsvStore to the ID of the email message that needs to be stored, and open it in the write mode.

  3. Use any of the following CMsvPlainBodyText::StoreChunkL() methods to store incoming data:

    1. const TDesC8 &aChunk, TRequestStatus &aStatus

    2. const TDesC8 &aChunk

    3. const TDesC16 &aChunk, TRequestStatus &aStatus

    4. const TDesC16 &aChunk

  4. After the entire email message has been received from the external server, the MTM must call the CommitL() method of CMsvPlainBodyText to complete the store operation.

Note: The email server MTM can store the email message that is received from the external server either as 8 or 16 bit. When the MTM calls the 16 bit version of the

StoreChunkL() function, and based on the charset information, it must convert the data to Unicode.

If the 8 bit version of theStoreChunkL() function is used for storing, and if the MTM wants the email message to be stored as 16 bit (this is indicated by the TBoolaIs8Bit parameter of InitialisePlainBodyTextForWriteL()), CMsvPlainBodyText converts and stores the email message in 16 bit based on the charset information provided while initialising CMsvPlainBodyText.

Related concepts