SendAs v2.0

Description

The application establishes a session with the SendAs server, sets a message entry, creates a message, sets its body text, adds a recipient, sends the message and closes the session. The sequence of events is detailed in the following list:

  • Create a session with the SendAs server using CMsvSession::OpenSyncL(MMsvSessionObserver &) function.

  • Set the message entry using the CMsvEntry::SetEntryL(TMsvId) function.

  • After setting the entry, the application gets a selection containing the IDs of all the context children, using the CMsvEntry::ChildrenL()const function.

  • The connection to the server is made using the default number of message slots available to a session, which is 4, (KSendAsDefaultMessageSlots).

  • The draft folder is emptied, before creating a new message.

  • Fetch the names and UIDs for the filtered list of message types using the RSendAs::FilteredMessageTypesL() function to create a SendAs message. Then the UID based on the message type is returned, and with the entry set on the drafts folder a SendAs message is created by calling the RSendAsMessage::CreateL(RSendAs &,TSendAsAccount) function.

  • Set a body text for the message and specify the recipients. In this example, the body text is set using an option, which is read from the user. Option given to the user are '1' for 8-bit encoding, '2' for 16-bit encoding and '0' or by default its unicode type of encoding. The encoded descriptor is set as the message's body text using the RSendAsMessage::SetBodyTextL(const CRichText &)function.

  • The recipients are added using the RSendAsMessage::AddRecipientL(const TDesC &,TSendAsRecipientType) function. The recipient's address is held in a descriptor. The alias is the displayed recipient name.

  • The recipient type is one of the TSendAsRecipientType enumeration values, that is, one of the following:

    • ESendAsRecipientTo - The recipient goes in the 'To' field.

    • ESendAsRecipientCc - The recipient goes in the 'Cc' field

    • ESendAsRecipientBcc - The recipient goes in the 'Bcc' field

    If the 'Cc' field is not supported, the recipient will instead be added to the 'To' field since these are functionally equivalent.

    If the 'Bcc' field is not supported, this function will return KErrNotSupported.

The example also displays the names of the accounts present in the list.

To demonstrate this, 3 new accounts are appended and they are displayed in a for-loop by calling CSendAsAccounts::AccountNames().MdcaPoint(i), where the MdcaPoint() function takes in the integer value of the current iteration in the for-loop and indexes into a descriptor array.

The example also demonstrates how to refine the available message types of the connected session using the RSendAs::FilterAgainstCapability() function.

The RSendAsMessage::SendMessage() function is used asynchronously to send the message. Finally the RsendAs::Close() function is used to end the session with SendAs server.

Download

Click on the following link to download the example: sendAs.zip

Click: browse to view the example code.

Build

The Symbian build process describes how to build an application.

The SendAs example builds an executable called SendAs2Example.exe in the standard location (\epoc32\release\winscw\ <build_variant> for CodeWarrior). After launching the executable, depending on the emulator you are using, you may need to task away from the app launcher/shell screen to view the console.