Sending Emails with RSendAs
Article Metadata
Tested with
Devices(s): Nokia E61i, Nokia C7-00
Platform Security
Capabilities: NetworkServices
Article
Keywords: messages
Created: everyourgokul
(24 Apr 2007)
Reviewed: Rostgrm
Last edited: rostgrm
(11 Jan 2013)
Code for sending emails
For sending emails the following code can be used.
Warnings
- Common:
- setup at least one email account or you will have KErrNotFound leaves
- 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.
- 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.libSource 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("you@me.com"), RSendAsMessage::ESendAsRecipientTo );
sendAsMessage.SetBodyTextL( _L("somebody@world.com") );
TRequestStatus status;
// adding attachments. Be sure file exists :)
sendAsMessage.AddAttachment( _L("c:\\splash.bmp"), status );
User::WaitForRequest( status );
sendAsMessage.SendMessageAndCloseL();
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

