Freestyle Email API


This is the mail API and framework used by the Freestyle email client. It provides access to the message store for reading email and to the sync engine for starting and stopping synchronizations.

Typical Usage From UI

// Initialize the access to the mail framework CFSMailClient* mail = CFSMailClient::NewL(); CleanupClosePushL(*mail);

// List mailboxes for user to select which one to open RPointerArray<CFSMailBox> mailBoxes; mailBoxes.Reset(); TFSMailMsgId plugin; // null id if all mailboxes required mail->ListMailBoxes(plugin,mailBoxes); // Lets select the first one this time CFSMailBox * currentMailbox = mailboxes[0];

// list all mailbox folders for user RPointerArray<CFSMailFolder> folders = currentMailBox->ListFolders( );

// or get default folder, for example inbox TFSMailMsgId folderId; folderId = mailBox->GetStandardFolderId( EFSInbox ); CFSMailFolder* inbox = mail->GetFolderByUid(currentMailBox->GetId(),folderId);

// List messages in inbox // select message details to be listed TFSMailDetails details(EFSMsgDataStructure);

// set sorting criteria TFSMailSortCriteria criteria; criteria.iField = EFSMailSortByDate; criteria.iOrder = EFSMailAscending; RArray<TFSMailSortCriteria> sorting; sorting.Append(criteria);

// get email list iterator from plugin MFSMailIterator* iterator = folder->ListMessagesL(details,sorting);

// list all messages from folder TFSMailMsgId currentMessageId; // first call contains NULL id as begin id RPointerArray<CFSMailMessage> messages; messages.Reset(); iterator->NextL(currentMessageId, folder->GetMessageCount(), messages);

// Show the first 5 messages to in the UI for(TInt i=0;i<messages.Count() && i<5;i++) { MyHeaderShowMethod(messages[i]->GetSender().GetEmailAddress(), messages[i]->GetSubject() messages[i]->GetDate());

// get email body CFSMailMessagePart* body = messages[i]->PlainTextBodyPartL(); if(body) { TBuf<n> text; TInt startOffset = 0; body->GetContentToBufferL(text,startOffset); MyPlainTextBodyShowMethod(text); delete body; }

//list email attachments RPointerArray<CFSMailMessagePart> attachments; attachments.Reset(); messages[i]->AttachmentListL(attachments); for(TInt i=0;i<attachments.Count();i++) { MyShowAttachmentNameMethod(attachments[i]->AttachmentName()); } attachments.ResetAndDestroy(); }

// clean iterator and tables messages.ResetAndDestroy(); delete iterator; sorting.Reset(); delete folder;

// User should call close when terminating mail framework usage // when shutting down application close mail client singleton CleanupStack::PopAndDestroy(mail);

Observing Email Events.

// To be able to observe events an user has to // implement MFSMailEventObserver interface. // Here the COwnMailObserver class implements the interface. COwnMailObserver* ownObserver = COwnMailObserver::NewL();

// Register to observe mail store events mail->AddObserverL(*ownObserver);

// Now callbacks are done via the EventL function defined // in the MFSMailEventObserver and implemented in this case // by the COwnMailObserver

// When user does not wish to observe events anymore // he has to unregister mail->RemoveObserver( *ownObserver );

// Remember that it must be done for each observer // in the end of the observation because the AddObserverL // does not replace the observer


The following classes form the public API of the frame work.

More Information

Copyright © 2006 Nokia. All rights reserved.

This material, including documentation and any related computer programs, is protected by copyright controlled by Nokia. All rights are reserved. Copying, including reproducing, storing, adapting or translating, any or all of this material requires the prior written consent of Nokia. This material also contains confidential information which may not be disclosed to others without the prior written consent of Nokia.