Hi All,
I am new to MTMs & email usage in s60.
For one of our self project implementation we have a trigger a email based on certain events.
To send a email, i went through the wiki.forum.nokia and got one example code to do that.
http://www.symbian.com/developer/tec...view.html#_top
I went through the above link and modified few constant values accroding to gmail server. ( server adress, pop3 server address, login name, password ). Like below.
_LIT(KTextPressAKey, "\n\n Press any key to step through the example");
_LIT(KExit,"\n\n Press any key to exit the application ");
_LIT(KCreateMtm,"\n\n Creating a Pop3 client MTM");
_LIT(KKeyPress,"\n\n Press any key");
_LIT(KTxtAccountName, "PopAccount");
_LIT(KCreatePopAccount,"\n\n Creating a Pop account");
_LIT(KCreateSmtpAccount,"\n\n Creating an Smtp account");
_LIT(KSmtpServerAddress, "ban-sindhub01.intra");
_LIT(KEmailAlias, "Messaging example");
_LIT(KSmtpEmailAddress, "smtp.gmail.com");
_LIT8(KFrom, "smanikandan14@gmail.com");
_LIT(KTo, "smani14@gmail.com");
_LIT(KSubject, "SimpleEmail");
_LIT(KBodyContents, "This is a very simple mail");
_LIT(KSendMail,"\n\n Sending the mail... please wait");
_LIT(KPopServer, "pop.gmail.com");
_LIT8(KPopPassword,"joliee");
_LIT8(KPopLoginName,"smanikandan14");
_LIT(KWait,"\n\n Connecting to pop3 server");
_LIT(KDownload,"\n\n Downloading mail from the pop3 server");
_LIT(KDisconnect,"\n\n Press any key to disconnect");
Then changed the port and made SSL enabled as told in the gmail configurations in the below code
void CPop3Example::CreatePopAndSmtpAccountL()
{
CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
CImPop3Settings* settings = new(ELeave) CImPop3Settings();
CleanupStack::PushL(settings);
CImIAPPreferences* popIAP = CImIAPPreferences::NewLC();
// Set the server address to system address
settings->SetServerAddressL(KPopServer);
settings->SetLoginNameL(KPopLoginName);
settings->SetPasswordL(KPopPassword);
settings->SetSSLWrapper(ETrue);
settings->SetPort(995);
// Create a Pop account
iConsole->Printf(KCreatePopAccount);
iPopAccount = emailAccounts->CreatePopAccountL(KTxtAccountName, *settings,*popIAP,EFalse);
CImSmtpSettings *smtpSettings = new (ELeave) CImSmtpSettings();
CleanupStack::PushL(smtpSettings);
emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings, *popIAP);
// Create an Smtp acoount
iConsole->Printf(KCreateSmtpAccount);
iSmtpAccount = emailAccounts->CreateSmtpAccountL(iPopAccount, *smtpSettings, *popIAP, EFalse);
emailAccounts->SetDefaultSmtpAccountL(iSmtpAccount);
smtpSettings->SetServerAddressL(KSmtpServerAddress);
smtpSettings->SetEmailAliasL(KEmailAlias);
smtpSettings->SetEmailAddressL(KSmtpEmailAddress);
smtpSettings->SetReplyToAddressL(KSmtpEmailAddress);
smtpSettings->SetReceiptAddressL(KSmtpEmailAddress);
smtpSettings->SetSSLWrapper(ETrue);
smtpSettings->SetPort(465);
// Add IAP to the IAP preferences
CImIAPPreferences* prefs = CImIAPPreferences::NewLC();
TImIAPChoice iap;
TInt iapID = 0;
CMDBSession* dbSession = CMDBSession::NewL(CMDBSession::LatestVersion());
CleanupStack::PushL(dbSession);
CCDConnectionPrefsRecord *connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord));
CleanupStack::PushL(connPrefRecord);
// Set the direction of connection
connPrefRecord->iDirection = ECommDbConnectionDirectionOutgoing;
connPrefRecord->iRanking = 1;
if(!connPrefRecord->FindL(*dbSession))
{
User::Leave(KErrNotFound);
}
iapID = connPrefRecord->iDefaultIAP;
iap.iIAP = iapID;
iap.iDialogPref = ECommDbDialogPrefDoNotPrompt;
prefs->AddIAPL(iap);
emailAccounts->GetSmtpAccountL(iSmtpAccount.iSmtpService, iSmtpAccount);
emailAccounts->SaveSmtpSettingsL(iSmtpAccount,*smtpSettings);
emailAccounts->SaveSmtpIapSettingsL(iSmtpAccount, *prefs);
CleanupStack::PopAndDestroy(7,emailAccounts); //connPrefRecord,dbSession,prefs,smtpSettings,popIAP,settings,emailAccounts
}
Then i compiled the code as given in that link.
After execution i could see a new mailbox created under messaging->mailbox.
And the mail which is sent through this code lies under 'outbox' folder and it is queued. It didnt go to the smtp server.
Can anyone help in this ? what could be the reason ? is the code in the above exmaple is proper. ?
Is changing the smtp port number to 465 could cause the problem ? any idea..
Can anyone share a code which is able to send a email properly without issues.
Thanks,
Mani




