reading MailBox entries

Login to reply to this topic.
Mon, 2005-08-01 08:11
Joined: 2004-12-23
Forum posts: 239
Hi All

How can I read all the entries of MailBox.
Any help.
Regards

---------------
Bhatt Kavita


Mon, 2005-08-01 09:30
chishti_hameed (not verified)
Forum posts: 2043
Re: reading MailBox entries
Quote from: mesweetie
Hi All

How can I read all the entries of MailBox.
Any help.
Regards




CMsvSession* pMsv = CMsvSession::OpenSyncL(*this);
CMsvEntry* pMsvEntry = pMsv->GetEntryL(KMsvGlobalInBoxIndexEntryId);

for(TInt i=0;i<pMsvEntry->Count();i++)
   {       
         TBuf<100> buf;
        buf.Append((*pMsvEntry)[i].iDetails);
      
        buf.Append((*pMsvEntry)[i].iDescription);      
   
}
Mon, 2005-08-01 10:14
Joined: 2004-12-23
Forum posts: 239
Re: reading MailBox entries
Hi hameed
Thanks for ypour reply.
But my question was how can i read all the entries of userdefined mailbox not inbox.
Can u help me..
Might be I have not clear my problem bit clear.Sorry for that.
Hoping for reply
Thanks

---------------
Bhatt Kavita

Mon, 2005-08-01 11:37
Joined: 2004-12-03
Forum posts: 192
Re: reading MailBox entries
use ID of your mailbox instead of KMsvGlobalInBoxIndexEntryId
Mon, 2005-08-01 11:41
Joined: 2004-12-23
Forum posts: 239
Re: reading MailBox entries
Thanks CORE[RUS}
but from where to get mailbox id.
Is it predefined or have to feteched out from some fuction.
Can u explore the solution pls..
How can i read the entries

---------------
Bhatt Kavita

Mon, 2005-08-01 11:42
chishti_hameed (not verified)
Forum posts: 2043
Re: reading MailBox entries
Quote from: mesweetie
Thanks CORE[RUS}
but from where to get mailbox id.
Is it predefined or have to feteched out from some fuction.
Can u explore the solution pls..
How can i read the entries
its predefined, look in sdk
Mon, 2005-08-01 11:46
Joined: 2004-12-23
Forum posts: 239
Re: reading MailBox entries
Thanks Hameed

I Got following Ids

// Predefined entry ids - values #defined in MSVSTD.HRH
const TMsvId KMsvNullIndexEntryId=KMsvNullIndexEntryIdValue;//0
const TMsvId KMsvTempIndexEntryId=KMsvTempIndexEntryIdValue;//1
const TMsvId KMsvRootIndexEntryId=KMsvRootIndexEntryIdValue;//0x1000
const TMsvId KMsvLocalServiceIndexEntryId=KMsvLocalServiceIndexEntryIdValue;//0x1001
const TMsvId KMsvGlobalInBoxIndexEntryId=KMsvGlobalInBoxIndexEntryIdValue;//0x1002
const TMsvId KMsvGlobalOutBoxIndexEntryId=KMsvGlobalOutBoxIndexEntryIdValue;//0x1003
const TMsvId KMsvDraftEntryId=KMsvDraftEntryIdValue; //0x1004
const TMsvId KMsvSentEntryId=KMsvSentEntryIdValue; //0x1005
const TMsvId KMsvDeletedEntryFolderEntryId=KMsvDeletedEntryFolderEntryIdValue;//0x1006
const TMsvId KMsvUnknownServiceIndexEntryId=KMsvUnkownServiceIndexEntryIdValue; //0x1007
const TMsvId KFirstFreeEntryId=0x100000;

which One should I use for mailbox and which one for MyFolder.
Can u help me hameed.


---------------
Bhatt Kavita

Mon, 2005-08-01 12:24
Joined: 2004-12-03
Forum posts: 192
Re: reading MailBox entries
IDs of user-folders are not predefined

use something like this:
Code:
CMsvEntry *localServiceEntry = session->GetEntryL(KMsvLocalServiceIndexEntryId);
CleanupStack::PushL(localServiceEntry);
CMsvEntrySelection *folders = localServiceEntry->ChildrenWithTypeL(KUidMsvFolderEntry);
CleanupStack::PushL(folders);

TInt count = folders->Count();
for (TInt i = 0;i < folderCount;i++)
{
TMsvEntry entry = localServiceEntry->ChildDataL((*folders)[i]);
// do something here... (e.g., entry.Id() gives you an ID of folder)
}

CleanupStack::PopAndDestroy(2); // localServiceEntry, folders
Mon, 2005-08-01 12:50
Joined: 2004-12-23
Forum posts: 239
Re: reading MailBox entries
Thanks Core[RUS]

I am trying like this

iSession=CMsvSession::OpenSyncL(*this);
CMsvEntry   *entry = iSession->GetEntryL(KMsvLocalServiceIndexEntryId);
CleanupStack::PushL(entry);
CMsvEntrySelection   *entries= entry->ChildrenWithTypeL(KUidMsvFolderEntry);
CleanupStack::PushL(entries);

TInt   count = entries->Count();
for (TInt i = 0;i < count ;i++)
{
   TMsvEntry   entryId =entry->ChildDataL((*entries)[i]);
   TMsvId id=entryId.Id();
   entry->DeleteL(id);//getttng system err -21
   // do something here... (e.g., entry.Id() gives you an ID of folder)
}

CleanupStack::PopAndDestroy(2); //
}

I wants to delete all the entries of myfolder present in Messaging Application.


---------------
Bhatt Kavita

Mon, 2005-08-01 13:04
Joined: 2004-12-03
Forum posts: 192
Re: reading MailBox entries
the array contains system folders (inbox, outbox, ...) too

find your mailbox (entry.iDetails.Compare(KMyMailbox)), then get its children and delete'em
Mon, 2005-08-01 13:06
Joined: 2004-12-03
Forum posts: 192
Re: reading MailBox entries
btw, it would be better to create this topic in `messaging` forum
Fri, 2005-08-05 11:13
Joined: 2004-12-23
Forum posts: 239
Re: reading MailBox entries
Thanks

TMsvId id=entryId.Id();
I m getting Ids
But how will i Identify that this is for Myfolder or for mailbox

---------------
Bhatt Kavita

Fri, 2005-08-05 11:57
Joined: 2004-12-03
Forum posts: 192
Re: reading MailBox entries
what a slowwitted programmer >:[

Code:
if (!entry.iDetails.Compare(KMyMailbox)))
{
   myId = entry.Id();
   break;
}
gives you ID of your mail box

after cycle
Code:
if (myId)
{
CMsvEntry *myFolder = iMsvSession->GetEntryL(myId);
CleanupStack::PushL(myFolder);
CMsvEntrySelection *myEntries = myFolder->ChildrenL();
CleanupStack::PushL(myEntries);

CMsvOperationWait *theWaiter = CMsvOperationWait::NewLC(CActive::EPriorityHigh);
CMsvOperation *theOp = myFolder->DeleteL(*myEntries, theWaiter->iStatus);
CleanupStack::PushL(theOp);

theWaiter->Start();
CActiveScheduler::Start();
User::LeaveIfError(theWaiter->iStatus.Int());

CleanupStack::PopAndDestroy(4); // myFolder, myEntries, theWaiter, theOp
}
deletes its entries
Fri, 2005-08-05 12:23
Joined: 2004-12-23
Forum posts: 239
Re: reading MailBox entries
ok thanks
if (!entry.iDetails.Compare(KMyMailbox)))
{
   myId = entry.Id();
   break;
}
here KMyMailbox may differ for different phones.
Say i have configured my mailbox as kavita
now i can compare it with KMyMailBox
but wht for other phones where i don;t know the details...
That i was asking how will i identify that this particular id refers to inbox.or outbox or myfolder or mailbox.
Hope u r getting me



Thanks

---------------
Bhatt Kavita

Fri, 2005-08-05 12:38
Joined: 2004-06-11
Forum posts: 404
Re: reading MailBox entries
Ya but the remaining 4 folders are same on each phone. Roll Eyes





Fri, 2005-08-05 12:50
Joined: 2004-12-23
Forum posts: 239
Re: reading MailBox entries
Quote
Ya but the remaining 4 folders are same on each phone.

Thanks Mayur
but I am stucked with the problem
I m getting ids
and ids are 4098,4099,4100,4101,4104
and the hexadecimal values for
Inbox is 0x1001
SentFolder 0x1005
Outbox 0x1003
Draft 0x1004

even if I convert these hexadecimal into decimal i m not getting these ids
so how will i compare that this partiular id is for mailbox/myfolder
as for inbox draft and sentfolder i have successfully read the entries by simply passing KMsvDraftEntryId and likewise for inbox,sentfolder...

And as Core[RUS]suggested me to use KMyFolder literal ok this could be done if i know hte details in advance but programmatically how will i compare if i don;t know the mailbox name....
So CORE{RUS} and Mayur could you please ponder over my problem.
TIA


---------------
Bhatt Kavita

  • Login to reply to this topic.