Namespaces
Variants
Actions
Revision as of 04:25, 15 June 2012 by hamishwillee (Talk | contribs)

Archived:Sending an e-mail using CSendAs

Jump to: navigation, search
Archived.png
Archived: 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

Article
Created: User:Technical writer 1 (08 Feb 2008)
Last edited: hamishwillee (15 Jun 2012)

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.

93 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved