Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Sending Emails with RSendAs

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia E61i, Nokia C7-00
Platform Security
Capabilities: NetworkServices
Keywords: messages
Created: everyourgokul (24 Apr 2007)
Reviewed: Rostgrm
Last edited: hamishwillee (14 Jun 2013)

Code for sending emails

For sending emails the following code can be used.


  1. Common:
    • setup at least one email account or you will have KErrNotFound leaves
  2. Devices:
    • sends well since 9.1 without capabilities
    • on Belle devices and above the message is saved to Drafts. If you add NetworkServices it will be sent succesfully.
  3. Emulator prerequisites
    • be sure you have the file at <SDK_PATH>\Epoc32\winscw\c\splash.bmp

Header Required:

#include <rsendas.h>
#include <rsendasmessage.h>
#include <senduiconsts.h>

Library needed:

LIBRARY  sendas2.lib

Source File:

    RSendAs session;
User::LeaveIfError( session.Connect() );
CleanupClosePushL( session );
RSendAsMessage sendAsMessage;
sendAsMessage.CreateL( session, KSenduiMtmSmtpUid );
CleanupClosePushL( sendAsMessage );
sendAsMessage.SetSubjectL( _L("Welcome back to symbian") );
//adding 'TO' field
sendAsMessage.AddRecipientL( _L(""), RSendAsMessage::ESendAsRecipientTo );
sendAsMessage.SetBodyTextL( _L("") );
TRequestStatus status;
// adding attachments. Be sure file exists :)
sendAsMessage.AddAttachment( _L("c:\\splash.bmp"), status );
User::WaitForRequest( status );
CleanupStack::Pop( &sendAsMessage );
CleanupStack::PopAndDestroy( &session );

The example in original paper was remade from book 'Symbian OS Communications Programming', author Iain Campbell, published in 2007

This page was last modified on 14 June 2013, at 06:57.
34 page views in the last 30 days.