void CMtfTestActionSetImap4ServiceParameters::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetImap4ServiceParameters);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
	TInt paramConfigIndex = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2),0);

	CImImap4Settings* settings = new(ELeave) CImImap4Settings();
	CleanupStack::PushL(settings);
	TPtrC fileName = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfImap4Settings,paramConfigIndex);
	iParser = CMtfTestActionUtilsConfigFileParser::NewL(fileName);
	
	settings->Reset();

	TPtrC serverName;
	User::LeaveIfError(iParser->GetFieldAsString(KServerName,serverName));
	settings->SetServerAddressL(serverName);

	CMtfTestActionUtilsConfigFileMachineName* machineNameFile = NULL;

	TPtrC emailAddressExtension;
	if (iParser->GetFieldAsString(KEmailAddressExtension, emailAddressExtension) == KErrNone)
		{
		machineNameFile = CMtfTestActionUtilsConfigFileMachineName::NewLC(emailAddressExtension);
		}
	else
		{
		machineNameFile = CMtfTestActionUtilsConfigFileMachineName::NewLC(serverName);
		}

	TPtrC8 machineName(machineNameFile->MachineName());

	TPtrC8 loginName;
	if(iParser->GetFieldAsString8(KLoginName,loginName)==KErrNone)
		{
		settings->SetLoginNameL(loginName);	
		}
	else
		{
		settings->SetLoginNameL(machineName);	
		}

	TPtrC8 password;
	if(iParser->GetFieldAsString8(KPassword,password)==KErrNone)
		{
		settings->SetPasswordL(password);	
		}
	else
		{
		settings->SetPasswordL(machineName);	
		}

	TPtrC8 folderPath;
	TInt err = iParser->GetFieldAsString8(KFolderPath,folderPath);
	if (err == KErrNone)
		settings->SetFolderPathL(folderPath);
	
	TPtrC8 imapSearchString;
	err = iParser->GetFieldAsString8(KImapSearchString,imapSearchString);
	if (err == KErrNone)
		settings->SetSearchStringL(imapSearchString);

	TInt emailDeleteFlag;
	err = iParser->GetFieldAsInteger(KEmailDeleteFlag,emailDeleteFlag);
	if (err == KErrNone)
		settings->SetDeleteEmailsWhenDisconnecting(emailDeleteFlag);

	TInt autoSendFlag;
	err = iParser->GetFieldAsInteger(KAutoSendFlag,autoSendFlag);
	if (err == KErrNone)
		settings->SetAutoSendOnConnect(autoSendFlag);	
	
 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
 	TImapAccount imapAccount;
 	accounts->GetImapAccountL(paramServiceId, imapAccount);
 	accounts->SaveImapSettingsL(imapAccount, *settings);
 	//Pop and destroy settings, machineNameFile and accounts
	CleanupStack::PopAndDestroy(3, settings);    
	
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetImap4ServiceParameters);	
	
	TestCase().ActionCompletedL(*this);
	}
LOCAL_C void InitL()
	{
	// Load the serial comms device drivers.  If this is not done,
	// connecting via NT-RAS returns KErrNotFound (-1).
	TInt driverErr;
	driverErr=User::LoadPhysicalDevice(PDD_NAME);
	if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists)
		User::Leave(driverErr);
	driverErr=User::LoadLogicalDevice(LDD_NAME);
	if (driverErr!=KErrNone && driverErr!=KErrAlreadyExists)
		User::Leave(driverErr);

	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
	CActiveScheduler::Install(scheduler);
	CleanupStack::PushL(scheduler);
	testUtils = CEmailTestUtils::NewLC(test);
	testUtils->CreateAllTestDirectories();
	testUtils->FileSession().SetSessionPath(_L("C:\\"));
	testUtils->CleanMessageFolderL();
	testUtils->GoServerSideL();
    testUtils->ClearEmailAccountsL();
	test.Next(_L("Create Data Component FileStores"));
	testUtils->CreateSmtpServerMtmRegL();
	//	Loading the DLLs
	testUtils->CreateRegistryObjectAndControlL();
	testUtils->InstallSmtpMtmGroupL();
	testUtils->GoClientSideL();
	// Create Services
	smtpService = testUtils->CreateSmtpServiceL();
	imap4Service = testUtils->CreateImapServiceL();
	CEmailAccounts* accounts = CEmailAccounts::NewLC();
	TSmtpAccount smtpAccount;
	accounts->GetSmtpAccountL(smtpService, smtpAccount);
	accounts->SetDefaultSmtpAccountL(smtpAccount);
    testUtils->WriteComment(_L("Create  Imap   Services           ")); 
	// Delete any *.scr files in c:\logs\email directory.
	testUtils->DeleteScriptFilesFromLogsDirL();

	testUtils->iMsvEntry->SetEntryL(imap4Service);
	//overwrite the settings with test code one.  Don't want the default settings.
	CImImap4Settings* settings = new(ELeave) CImImap4Settings();
	CleanupStack::PushL(settings);
	settings->Reset();
	TInt serverLength = testUtils->MachineName().Length();
	HBufC* serverad = HBufC::NewL(serverLength + 7 ); // 7 is the length of KServerAddress
	CleanupStack::PushL(serverad);
	serverad->Des().Copy(testUtils->MachineName());
	serverad->Des().Append(KServer);
	settings->SetServerAddressL(*serverad);
	CleanupStack::PopAndDestroy(serverad); 
	settings->SetDeleteEmailsWhenDisconnecting(ETrue);
	settings->SetAcknowledgeReceipts(ETrue);
	settings->SetAutoSendOnConnect(ETrue);
	settings->SetLoginNameL(testUtils->MachineName());
	settings->SetPasswordL(testUtils->MachineName());
   	settings->SetPort(143);
	settings->SetFolderPathL(KFolderPath);
	accounts->GetImapAccountL(imap4Service, imapAccount);
	accounts->SaveImapSettingsL(imapAccount, *settings);
	CleanupStack::PopAndDestroy(2,accounts); //accounts,settings
	test.Printf(_L("Instantiating IMAP4 Client MTM"));
	testUtils->InstantiateImapClientMtmL();
	}