Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Regular Contributor
Posts: 59
Registered: ‎03-06-2012
My Device: 9700
My Carrier: airtel
Accepted Solution

Read email id configured in device in the app

Hello ,

 

        I wanted to read the email id which is configured in device ,how to read the email id configured using email set up? I wanted to read the email id in the app ,how to do so?

 

Thanks,

Sheetal

Forums Veteran I
Posts: 1,847
Registered: ‎12-20-2011
My Device: Playbook 2.1/ Torch9860 OS7.1.0.746
My Carrier: Globe

Re: Read email id configured in device in the app

If you configured an email thru the email setup, there should be a dedicated email icon that will be added on your homescreen and that is where you can easily access you emails.


Ron
...........................................................................................................................................................
Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up Smiley Happy

Blackberry Battery Saving Tips | Follow me on Twitter

Regular Contributor
Posts: 59
Registered: ‎03-06-2012
My Device: 9700
My Carrier: airtel

Re: Read email id configured in device in the app

My query was ,how can i get email id congifured in the application,i want the api to read the email id's ?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Read email id configured in device in the app

Can I recommend the Search box, you will find answers to questions like this quickly (and a lot more as well!).  For example I found this using the Search "device email address".

 

http://supportforums.blackberry.com/t5/Java-Development/Retrieve-the-default-email-address-for-the-d...

Regular Contributor
Posts: 59
Registered: ‎03-06-2012
My Device: 9700
My Carrier: airtel

Re: Read email id configured in device in the app

Thanks Peter,i will try this out,can you also tell me if this will alos return a list of email id configured,that is in case if i haveconfigured  -5 email accounts then how will i retrieve all those email id in my app ?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Read email id configured in device in the app

As noted before, I recommend you use Search and try to find the answers to your own questions.

 

Ths might help:

http://supportforums.blackberry.com/t5/Java-Development/Send-a-message-from-a-non-default-email-addr...

Regular Contributor
Posts: 59
Registered: ‎03-06-2012
My Device: 9700
My Carrier: airtel

Re: Read email id configured in device in the app

I am new blackberry,i did not found solutions yet,i have seen the link ,but it shows sending message to the email accounts ,i am not getting where it has retrieved the email id associated /configured in the device ?
Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: Read email id configured in device in the app

Hi,

 

Peter is already post the solution for your problem, in this thread peter first post link helps your problem take look in that link..

 

Regards,

Lakshman K

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Regular Contributor
Posts: 59
Registered: ‎03-06-2012
My Device: 9700
My Carrier: airtel

Re: Read email id configured in device in the app

[ Edited ]

I have seen both the links i am trying to to retrive the list of mail ID that are configured in blackberry device.Not just the default one,may be i am not getting the solution in link can u pls explain the same

/get the default session

Session session = Session.getDefaultInstance();


If (session != null) {

//now the store

Store store = session.getStore();

//then the service configuration

ServiceConfiguration serviceConfig = store.getServiceConfiguration();


//now get the email address

String emailAddress = serviceConfig.getEmailAddress();

}
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Read email id configured in device in the app

Have you seriously searched the forum and looked at all the entries and tried to figure it out for yourself? 

 

Promise me next time you will.

 

        /**
        * Get the Default Email Address associated with this device
        * @return - String containing the default email address - null if none.
        */
        public static String getOurEmailAddress() {
                // Shared routine to get this BlackBerry's default email address
                String emailAddress;
                try {
                        Session ourSession = Session.getDefaultInstance();
                        // This returns null if BB does not have a Message Service - which means next
                        // instruction will get a null pointer exception.
                        emailAddress = ourSession.getServiceConfiguration().getEmailAddress();
                } catch ( Exception e ) {
                        emailAddress = null;
                }
                if ( emailAddress != null && emailAddress.length() > 0 ) {
                        // So that we can be consistent, make sure email address is lower case
                        emailAddress = emailAddress.toLowerCase();
                }
                return emailAddress;
        }

        /**
        * Get all Email addresses associated with the device
        * @return - String array containing email addresses.
        */
        public static String [] getOurEmailAddresses() {
                // Shared routine to get all email addresses associated with this BlackBerry
                try {
                        ServiceBook sb = ServiceBook.getSB();
                        ServiceRecord[] srs = sb.getRecords();
                        String [] possibleEmailAddress = new String [srs.length];
                        String emailAddress = null;
                        int emailAddressCounter = 0; // count of number actually found
               
                        for ( int cnt = srs.length - 1; cnt >= 0; --cnt) {
                                //identify the service record associated with a mail message service via a CID of 'CMIME'
                                if( srs[cnt].getCid().equals( "CMIME" )) {
                                        ServiceConfiguration sc = new ServiceConfiguration(srs[cnt]);
                                        if ( sc != null ) {
                                                emailAddress = sc.getEmailAddress();
                                                if ( emailAddress != null && emailAddress.length() > 0 ) {
                                                        // To be consistent, make sure email addresses are lower case
                                                        possibleEmailAddress[emailAddressCounter] = emailAddress.toLowerCase();
                                                        emailAddressCounter++;
                                                }
                                        }
                                }
                        }
                        // Now have in possibleEmailAddress, emailAddressCounter email's
                        if ( emailAddressCounter == 0 ) {
                                return null;
                        }
                        String [] returnEmailAddresses = new String [emailAddressCounter];
                        for ( int i = 0; i < emailAddressCounter; i++ ) {
                                returnEmailAddresses[i] = possibleEmailAddress[i];
                        }
                        return returnEmailAddresses;
                } catch (Exception e) {
                        return null;
                }
        }