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 over the next few weeks. Thanks for all your past and future contributions.
Sending Emails with RSendAs
Code for sending emails
For sending emails the following code can be used.
- setup at least one email account or you will have KErrNotFound leaves
- 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.
- Emulator prerequisites
- be sure you have the file at <SDK_PATH>\Epoc32\winscw\c\splash.bmp
User::LeaveIfError( session.Connect() );
CleanupClosePushL( session );
sendAsMessage.CreateL( session, KSenduiMtmSmtpUid );
CleanupClosePushL( sendAsMessage );
sendAsMessage.SetSubjectL( _L("Welcome back to symbian") );
//adding 'TO' field
sendAsMessage.AddRecipientL( _L("firstname.lastname@example.org"), RSendAsMessage::ESendAsRecipientTo );
sendAsMessage.SetBodyTextL( _L("email@example.com") );
// 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