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


Vishal@Aggarwal - Getting System error(-1)
Hello, I am getting System error(-1) while running this code on Emulator. I am using carbide c++ v2.7 with s60_3rd edition sdk .. plz help me how to so that.
thanksVishal@Aggarwal 09:49, 5 July 2012 (EEST)
Hamishwillee - Debugging
This could mean virtually anything - its a not found error. You need to find out what isn't found at runtime. As this was written in 2007 it is likely the author won't respond, so for further help I suggest you check the developer library and also ask for help on the discussion boards.hamishwillee 05:06, 6 August 2012 (EEST)
Hamishwillee - Note, this has been updated by rostgrm and should now be compatible
Regards
Hamishhamishwillee 02:19, 21 January 2013 (EET)