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. Thanks for all your past and future contributions.

How to create Local Message Folder

From Wiki
Jump to: navigation, search
Article Metadata
Created: eswar_illuri (07 May 2007)
Last edited: hamishwillee (26 Jul 2012)
Local folders can be created under the global "Inbox" and under the "My Folders" folders. Access to other locations in the messaging tree is restricted to the system and particular MTMs that own those locations.

Hearders Required:

#include <msvapi.h> 
#include <msvstd.h >

Library required:

LIBRARY msgs.lib

To check if a custom folder already exists under the parent folder My Folders:

TBool CSmsHandler::Check()
CMsvEntry * entry = iSession->GetEntryL( KMsvMyFoldersEntryIdValue );
CleanupStack::PushL( entry );
CMsvEntrySelection * entries = entry->ChildrenWithTypeL(KUidMsvFolderEntry);
CleanupStack::PopAndDestroy( entry );
TInt nCount = entries->Count();
TInt found =0;
for ( TInt i=1; i < nCount; i++ )
TMsvId entryID = entries->At( i );
entry = iSession->GetEntryL( entryID );
CleanupStack::PushL( entry );
TMsvEntry msvEntry = entry->Entry();
TPtrC descr = msvEntry.iDetails;
if (descr.Compare(_L("MyToday"))==0)
found =1;
iNewFolderId=entryID ;
CleanupStack::PopAndDestroy( entry );
delete entries;
return found;

Two files need to be updated

  • msvids.h has to be updated with:
const TMsvId KMsvMyFoldersEntryId=KMsvMyFoldersEntryIdValue;
  • msvstd.hrh has to be updated with:
#define KMsvMyFoldersEntryIdValue 0x1008

To create a custom folder, you can use the following type and MTM settings for the index entry:

TMsvEntry mEntry;
mEntry.iMtm = KUidMsvLocalServiceMtm;
mEntry.iServiceId = KMsvLocalServiceIndexEntryId;
mEntry.iType = KUidMsvFolderEntry;

The following code shows how to create a folder named Wiki under My Folders

TMsvId msvServId;                                                                       
CMsvEntry *entry1 = NULL;
CMsvEntry * rootEntry = NULL;
CMsvEntry *entryRootService = NULL;
TInt newFldrID = 0;
//Get the entry (whatever is passed in)
entry1 = iSmsMtm->Session().GetEntryL(KMsvMyFoldersEntryIdValue);
if (entry1)
msvServId = entry1->OwningService();
entryRootService = iSmsMtm->Session().GetEntryL(msvServId);
rootEntry = iSmsMtm->Session().GetEntryL(msvServId);
rootEntry->SetEntryL(KMsvMyFoldersEntryIdValue); // set to parent
TMsvEntry newServiceEntry;
TTime ttime;
newServiceEntry.iDate = ttime;
newServiceEntry.iSize = 0;
newServiceEntry.iType = KUidMsvFolderEntry;
newServiceEntry.iMtm = KUidMsvLocalServiceMtm;
newServiceEntry.iServiceId = iSmsMtm->ServiceId();
newServiceEntry.iDetails.Set (_L("Wiki"));
newFldrID = newServiceEntry.Id();

Hence a folder Wiki is created in My Folders folder.

Related Links:

This page was last modified on 26 July 2012, at 02:42.
23 page views in the last 30 days.