Solved

How to programatically poll a mail server In symbian

Posted on 2006-06-12
3
923 Views
Last Modified: 2013-12-27
Hello,

I'd like to create a series60 application which launches the retrieval of new mails from a mailbox.
I've been able to retrive the id of the mailbox service but I don't know how to get new mails. I have tried with the following methods:
CImPOP3GetMail::GetMailL
and CPop3ClientMtm::InvokeAsyncFunctionL
but I do not manage to make it works.

Can someone help?

Note : Dont Tell me download the (Pop3_Imap4) Example in nokia website  because my case here is different from this example
Our telecom provider is not offering the email service although that the (GPRS) is working successfully.

Please take look on this posted threads:
http://www.experts-exchange.com/Programming/Wireless_Programming/EPOC/Q_21880941.html
http://www.experts-exchange.com/Programming/Wireless_Programming/EPOC/Q_21823903.html



Thanks,
0
Comment
Question by:mubama0n
  • 2
3 Comments
 

Author Comment

by:mubama0n
Comment Utility
Here Is The Code That I Have It breacks on the line:op=pop3Mtm->InvokeAsyncFunctionL(KPOP3MTMMoveMailSelectionWhenAlreadyConnected,*selection,dummyParams,waiter->iStatus);

The Complete Code Is Here:

void CDisplayMessageFolderContainer::GetInboxEmail()
{
      //--->The Original
//----->Making Some Feltiring for Incoming Messages
      CMsvEntryFilter* aFilter=CMsvEntryFilter::NewLC();
      TMsvSelectionOrdering* selectionOrder = new (ELeave) TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByDateReverse,ETrue);
      aFilter->SetOrder(*selectionOrder);
      CMsvEntrySelection* childSelection = new(ELeave) CMsvEntrySelection;
      iSession->GetChildIdsL(KMsvGlobalInBoxIndexEntryId,*aFilter,*childSelection);
      iEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
      CPop3ClientMtm* pop3Mtm = static_cast<CPop3ClientMtm*>(iMtmReg->NewMtmL(KUidMsgTypePOP3));
      CleanupStack::PushL(pop3Mtm);
      pop3Mtm->SwitchCurrentEntryL( iEntry->EntryId() );
//------>Setting And Saving Pop3 Account
      CImPop3Settings* tempsettings = new (ELeave) CImPop3Settings();
      CImPop3Settings &settings =tempsettings->CopyL(pop3Mtm->Settings());
      settings.Reset();
      settings.SetServerAddressL(KPOP3Server1);
      settings.SetLoginNameL(KPOP3LoginName1);
      settings.SetPasswordL(KPOP3Password1);
      settings.SetPort(KPop3Port1);
      settings.SetInboxSynchronisationLimit(0);
      settings.SetGetMailOptions(EGetPop3EmailMessages);
      CleanupStack::PushL(&settings);
      pop3Mtm->SetSettingsL(settings);
      //pop3Mtm->SwitchCurrentEntryL(iNewMessageId);
      //CMsvEntry* service=&pop3Mtm->Entry();//&clientMtm->Entry();//
      //CleanupStack::PushL( service );
      CMsvEntrySelection *selection = new(ELeave)CMsvEntrySelection;
      CleanupStack::PushL( selection );
      selection =pop3Mtm->Entry().ChildrenL();//pop3Mtm->Entry().ChildrenWithMtmL(KUidMsgTypePOP3);////service->ChildrenL();// // a selection of all entries in the mail box
      selection->AppendL(pop3Mtm->Entry().EntryId());
      //TBuf8<1> dummyParams;//dummy parameters needed for InvokesyncFunctionL
      CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
      _LIT(messageChanged,"Synchronization Will be Started");
      informationNote->ExecuteLD(messageChanged);
//---->For Asynchronouse Calls//KPOP3MTMIsConnected
//--->if we want to Use GetEmail Class
//--->
      CMsvOperation* op=NULL;
      CleanupStack::PushL(op);
      CMsvOperationWait* waiter=CMsvOperationWait::NewLC();//KPOP3MTMMoveMailSelectionWhenAlreadyConnected
      TBuf8<1> dummyParams;//KPOP3MTMConnectAndCopyMailSelectionAndDisconnect
      op=pop3Mtm->InvokeAsyncFunctionL(KPOP3MTMMoveMailSelectionWhenAlreadyConnected,*selection,dummyParams,waiter->iStatus);
      waiter->Start();
      CActiveScheduler::Start();
      CleanupStack::PopAndDestroy(waiter);
      CleanupStack::PopAndDestroy(op);
      CleanupStack::PopAndDestroy(selection);
      //if (selection != NULL)
      //{
      //CMsvOperation* op=pop3Mtm->InvokeAsyncFunctionL(KPOP3MTMConnectAndCopyMailSelectionAndDisconnect,*selection,dummyParams,stat);
      //}
      //CActiveScheduler::Start();
      _LIT(messageAfter,"Synchronization Ended");
      informationNote->ExecuteLD(messageAfter);
      //_LIT(messageAfter,"Synchronization Ended");
      //informationNote->ExecuteLD(messageAfter);
//------>
//---->End of The New Modifications
//---->Original
//---->End Of the Original
//------------------------------>Loop For Listing The Email Messages
      CDesCArray *array=(CDesCArray*)iListBox->Model()->ItemTextArray();
      CMsvEntrySelection *children=pop3Mtm->Entry().ChildrenL();//iEntry->ChildrenL();
    CleanupStack::PushL(children);
    _LIT(KItemFormat,"\t%S\t%S");
    TBuf<100> buf;
      TInt EmMesCount=0; ///--->To Count The Email Messages Not Other (e.g.:sms)
    for(TInt i=0;i<children->Count();i++)
    {
            //--->The Original
        //CMsvEntry *child=drafts->ChildEntryL((*children)[i]);
            CMsvEntry *child=pop3Mtm->Entry().ChildEntryL((*children)[i]);//iEntry->ChildEntryL((*children)[i]);
        const TMsvEntry &entry=child->Entry();
            if ( ( iSession->GetEntryL( children->At( i ) ) )->Entry().iMtm == KUidMsgTypePOP3)
            {
                  buf.Format(KItemFormat,&entry.iDescription,&entry.iDetails);
                  EmMesCount++;
            }
        delete child;
        array->AppendL(buf);
    }
      if (EmMesCount > 0)
      {
            CAknInformationNote* informationNote2 = new (ELeave)CAknInformationNote;
            informationNote2->ExecuteLD(_L("Getting Messages From Your Email"));
      }
    CleanupStack::PopAndDestroy(6);//(5); // (3)children, drafts, session
      //---->
      iListBox->Model()->SetItemTextArray(array);
      //iListBox->Model()->SetOwner
      iListBox->SetCurrentItemIndex(0);
      iListBox->SetFocus(ETrue);
}
void CDisplayMessageFolderContainer::ConstructL(const TRect& aRect)
//void CDisplayMessageFolderContainer::ConstructL(const TRect& aRect,CDisplayMessageFolderAppUi* aParent)
{      //----->New Statement
    CreateWindowL();
      iListBox=new(ELeave)CAknDoubleStyleListBox;
    iListBox->ConstructL(this,EAknListBoxSelectionList);
    iListBox->SetContainerWindowL(*this);
    //CDesCArray *array=(CDesCArray*)iListBox->Model()->ItemTextArray();
    SetRect(aRect);
    ActivateL();
      iListBox->SetSize(aRect.Size());
      iSession = CMsvSession::OpenAsyncL(*this);
      iMtmReg = CClientMtmRegistry::NewL( *iSession );
      iEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
}

void CDisplayMessageFolderContainer::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3) //HandleSessionEventL
{
//--->To Be Added When Needed
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
switch(aEvent)
{
// the messaging server is ready
case MMsvSessionObserver::EMsvServerReady:
{
TMsvId serviceId(KMsvRootIndexEntryId); // Pop3 service id
//TMsvId serviceId; // Pop3 service id
//serviceId=KMsvRootIndexEntryId;
// Determine if the event was succesful.
// ServiceProgress inserts TBuf8 value in progress.
TBuf8<KBfrLength> progress;
iSession->ServiceProgress( serviceId, progress );
_LIT8( KCompare, "KErrNone");
if ( progress.Compare( KCompare ))
{
//HBufC* text = StringLoader::LoadLC( "Email Session Server Starts" );
_LIT(ServerStarts,"Email Session Server Starts");
informationNote->ExecuteLD(ServerStarts);
//CleanupStack::PopAndDestroy( text );
// Check that MtmRegistry has not already been accessed.
if ( !iMtmReg )
{
iMtmReg = CClientMtmRegistry::NewL( *iSession );
//AccessMtmL();
}
if (!iEntry)
{
iEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
}
}
else
{
//HBufC* text = StringLoader::LoadLC( R_EMAIL_SESSION_ERROR );
_LIT(ServerFailed,"Email Session Server Faild To Start Error");
CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote;
errorNote->ExecuteLD(ServerFailed);
//CleanupStack::PopAndDestroy( text );
}
break;
}
//case MMsvSessionObserver::EMsvEntriesChanged:
case MMsvSessionObserver::EMsvEntriesCreated:
{
// We are interested in messages that are created in Inbox
_LIT(messageChanged,"Entries Created");
informationNote->ExecuteLD(messageChanged);
// Only look for changes in the Inbox
if (*(static_cast<TMsvId*>(aArg2)) == KMsvGlobalInBoxIndexEntryId)//KObservedFolderId)
{
CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
iNewMessageId = entries->At(0);
DisplayMessageL(iNewMessageId);
}
break;
//------------>

}
//case MMsvSessionObserver::EMsvEntriesCreated:
case MMsvSessionObserver::EMsvEntriesChanged:
{
_LIT(messageCreated,"Message Entries Changed");
informationNote->ExecuteLD(messageCreated);
if (*(static_cast<TMsvId*>(aArg2)) == KMsvGlobalInBoxIndexEntryId)
{
CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
if (iNewMessageId == entries->At(0))
{
// Set entry context to the new message
iEntry->SetEntryL(iNewMessageId);
// Check the type of the arrived message and that the message is complete.
// only SMS are our consern
if ( iEntry->Entry().iMtm != KUidMsgTypePOP3 || iEntry->Entry().iMtm != KUidMsgTypeIMAP4 || !iEntry->Entry().Complete() )
{
return;
}
}
// Read-only store.
//CMsvStore* store = iEntry->ReadStoreL();
//CleanupStack::PushL(store);
DisplayMessageL(iEntry->EntryId());
//CleanupStack::PopAndDestroy(store);
}
break;

}
//----->
case MMsvSessionObserver::EMsvCloseSession:
{
_LIT(messageClose,"Sesion Closed");
informationNote->ExecuteLD(messageClose);
iSession->CloseMessageServer();
break;
}
case MMsvSessionObserver::EMsvServerTerminated:
{
_LIT(messageTerminate,"Sesion Terminated");
informationNote->ExecuteLD(messageTerminate);
iSession->CloseMessageServer();
break;
}
case MMsvSessionObserver::EMsvGeneralError:
case MMsvSessionObserver::EMsvServerFailedToStart:
{
//iObserver.HandleEngineChangedEventL(MMsvObserver::EFatalServerError);
_LIT(messageError,"Error At The Messaging Server");
informationNote->ExecuteLD(messageError);
//iObserver.HandleError(MMsvObserver::EFatalServerError);
break;
}
//----->

break;
}
}
0
 

Author Comment

by:mubama0n
Comment Utility
It breaks (With Run time error) on the line:
op=pop3Mtm->InvokeAsyncFunctionL(KPOP3MTMMoveMailSelectionWhenAlreadyConnected,*selection,dummyParams,waiter->iStatus);
0
 

Accepted Solution

by:
EE_AutoDeleter earned 0 total points
Comment Utility
mubama0n,
Because you have presented a solution to your own problem which may be helpful to future searches, this question is now PAQed and your points have been refunded.

EE_AutoDeleter
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now