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
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

How to get Email address used by the phone

Hi guys.


Can I make an API that would pick up the email address used by the BB phone
You know BB setup wizard has email setup.
I am trying to get email address for this setup.


Is it possible ?
If so, please share your knowledge.

Thanks.
Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to get Email address used by the phone

get the servicebook, get the servicerecords, get the serviceconfiguration for each record and check if it has a mailaddress (getEmailAddress() )
the first is the address the device is registered to.
----------------------------------------------------------
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.
@SimonHain on twitter
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to get Email address used by the phone

Thanks Simon.

 

I've written some code by your idea.

 

Iam using JDE4.2.1. 

 

1. ServiceBook serviceBook = ServiceBook.getSB();

2. ServiceRecord[] serviceRecords = serviceBook.getRecords();

3. for(int i = 0; i < serviceRecords.length; i++) {

     4. String conf = get the serviceconfiguration

        if(checks conf as email address) {

               5. Found email address.

        }

}

 

I don't know how to get the serviceconfiguration.

 

Do you know method that gets serviceconfiguration ?

 

Thanks.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to get Email address used by the phone

you can create the serviceconfiguration using the servicerecord.
see http://www.blackberry.com/developers/docs/4.7.0api/net/rim/blackberry/api/mail/ServiceConfiguration....
----------------------------------------------------------
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.
@SimonHain on twitter
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to get Email address used by the phone

Thanks for your response.

 

So, I thought that following steps can get email address. 

 

1. ServiceBook serviceBook = ServiceBook.getSB();

2. ServiceRecord[] serviceRecords = serviceBook.getRecords();

3. for(int i = 0; i < serviceRecords.length; i++) {

4.     ServiceConfiguration sc = new ServiceConfiguration(serviceRecords[i]);

        String email = sc.getEmailAddress();

        if(IsEmailAddress(email)) {

               5. Found email address.

        }

}

 

Is it right ? 

 

Thanks.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to get Email address used by the phone

getEmailAddress can return null, you should check for this. Other than this it looks ok.
----------------------------------------------------------
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.
@SimonHain on twitter
Developer
Raiden
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: How to get Email address used by the phone

Ok, Thanks Simon.

I got it'

 

New Developer
pavelm
Posts: 4
Registered: ‎07-27-2009
My Device: Not Specified

Re: How to get Email address used by the phone

I believe there is a more direct way of getting the email address.

 

        Session mailSession = Session.getDefaultInstance();
        ServiceConfiguration config = mailSession.getServiceConfiguration();
        return config.getEmailAddress();

 

Is this more correct in getting the email address of the current blackberry user?

Regular Contributor
musmankhan90
Posts: 92
Registered: ‎03-09-2013
My Device: bold 9800

Re: How to get Email address used by the phone

Hello, Sir would you please send me sample code to check whether mail address is configured on device or not.  I am working on application which will first check that whether mail is configured on device or not.

Thanks

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

Re: How to get Email address used by the phone

[ Edited ]

The following KB article demonstrates how to use ALL email accounts registered on the phone.  I am sure you can rework this to detect if ANY email accounts are registered. 

 

If you have a new question, the normal practice is to start a new Thread. 

 

Please use the search facility before posting questions too. 

 

Edit:

Opps forgot the link - never mind, Simon has posted it:

http://supportforums.blackberry.com/t5/Java-Development/How-to-get-Email-address-used-by-the-phone/m...