How to fetch the configured Email id
This article explains how to fetch the configured Email id from the device , whether configured manually or through code.
Article Metadata
Tested with
Devices(s): N82, N97
Compatibility
Platform(s): S60 3rd Edition, FP1,FP2, S60 5th Edition
Platform Security
Signing Required: DevCert
Capabilities: ReadDeviceData
Article
Keywords: CEmailAccounts, CImSmtpSettings
Created: vineet.jain
(31 Aug 2011)
Last edited: kiran10182
(21 Feb 2012)
Introduction
The Email id as configured by the user is required sometimes in the applications for e.g. which require to set the Email as pre-filled field in an editor or form etc.
Summary
Headers required:
#include "cemailaccounts.h"
#include "SMTPSET.H"
Link Against:
LIBRARY imcm.libGet the Count of SMTP accounts configured on device & fetch the default one or if there are more then one then pass the index
CEmailAccounts* mailAccount = CEmailAccounts::NewLC();
RArray<TSmtpAccount> accountsSmtp(3);
TBuf8<60>iUserEmailId;
mailAccount->GetSmtpAccountsL(accountsSmtp);
TInt icountAccnt = accountsSmtp.Count();
if(icountAccnt>0)
{
iSmtpSettings = new(ELeave)CImSmtpSettings; // in class header : CImSmtpSettings*iSmtpSettings;
TSmtpAccount iSmtpAccount;
mailAccount->DefaultSmtpAccountL(iSmtpAccount);
or
const TSmtpAccount &iSmtpAccount= accountsSmtp.operator [](0); /// pass here the index
mailAccount->LoadSmtpSettingsL(iSmtpAccount,*iSmtpSettings);
iUserEmailId.Copy(iSmtpSettings->EmailAddress()); // iUserEmailId will contain the mail id as configured by the user
}
else
{
/// do your error handling here
}


lpvalente - Clarification
Can you please clarify what you mean by "The Email id as configured by the user is required sometimes in the applications for e.g. which require to set the Email as pre-filled field in an editor or form etc. " ? I did not understand this.
Vineet.jain - Clarification
I just referred to a condition in an application in which the user sometimes want to send an email to someone from the default email id as configured in his device, so it might be convenient to provide the user his default email id(let say pre-filled in some editior ) instead of making him enter it in the app.
Thanks
Vineetvineet.jain 07:32, 8 February 2012 (EET)