Namespaces

Variants
Actions

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.

Archived:Sending an e-mail using CSendAs

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Compatibility
Platform(s): S60 2nd Edition
S60 2nd Edition (initial release)
Article
Created: User:Technical writer 1 (08 Feb 2008)
Last edited: hamishwillee (14 Jun 2013)

Description

The following code demonstrates how to send an e-mail programmatically using CSendAs.

MSendAsObserver is an observer that allows the client application to receive notifications about capability checks. The client application must implement this interface in order to receive notifications.

Derive the MSendAsObserver mixin class and implement the callback function CapabilityOK():

 class CMyEmailEngine : public MSendAsObserver 
{
...
public:
// from MSendAsObserver
TBool CapabilityOK(TUid aCapability, TInt aResponse);
...
private:
CSendAs* iSendAs;
CRichText* iRichText;
CParaFormatLayer* iParaLayer;
CCharFormatLayer* iCharLayer;
};

Sending an e-mail

The following code snippet can be used to send an e-mail using CSendAs:

 iParaLayer=CParaFormatLayer::NewL();
iCharLayer=CCharFormatLayer::NewL();
//For creating the content of the mail
iRichText=CRichText::NewL(iParaLayer,iCharLayer);
//KBody is the content to be sent
iRichText->InsertL(0,KBody);
iSendAs->SetMtmL(KUidMsgTypeSMTP);
//Create the mesage in outbox.
iSendAs->CreateMessageL(KMsvGlobalOutBoxIndexEntryId);
//Set the subject of the mail
iSendAs->SetSubjectL(_L("First Email"));
//Add the recipient of the mail
//KRecipient is recievers mail address
iSendAs->AddRecipientL(KRecepient);
//Set the text of the message
iSendAs->SetBodyL(*iRichText);
//Save the message
iSendAs->SaveMessageL(ETrue);

Note that the e-mail is not sent immediately and remains in the outbox. The e-mail is sent by smtp MTM only when a new connection has been established with the remote server. The new connection can be established as follows:

1) Opening the messaging application and using the "Send" option (which you have used)

2) If the "automatic retrieval" option in mail settings is "ON", the connection is established according to the rules specified for the automatic retrieval of e-mails.

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

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×