Thanks For Help

On Aug 2, 9:19 pm, RAVINDER MAAN <[email protected]> wrote:
> u can use gdata to get ur gmail contacts and to send message you can use
> javamail.
>
> Below is code to get your contacts from gmail
>
> import java.io.IOException;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.util.ArrayList;
> import java.util.Iterator;
> import java.util.List;
>
> import com.google.gdata.client.Query;
> import com.google.gdata.client.contacts.ContactsService;
> import com.google.gdata.data.contacts.ContactEntry;
> import com.google.gdata.data.contacts.ContactFeed;
> import com.google.gdata.data.extensions.Email;
> import com.google.gdata.util.AuthenticationException;
> import com.google.gdata.util.ServiceException;
>
> public class GmailContacts {
>
> public static List<Contact> getConatacts(String email, String password)
> throws IOException, ServiceException {
> ContactsService service = new ContactsService(
> "Google-contactsExampleApp-3");
> service.setUserCredentials(email, password);
> URL url = new URL(
> "http://www.google.com/m8/feeds/contacts/"+email+"/thin";);
> Query myQuery = new Query(url);
> myQuery.setMaxResults(1000);
> ContactFeed resultFeed = service.query(myQuery, ContactFeed.class);
> List<Contact> contactList = new ArrayList<Contact>();
> for (ContactEntry entry : resultFeed.getEntries()) {
> List<Email> emailList = entry.getEmailAddresses();
> for (Iterator iterator = emailList.iterator(); iterator.hasNext();) {
>
> Email emailObj = (Email) iterator.next();
> contactList.add(new Contact(emailObj.getAddress(), entry
> .getTitle().getPlainText() == null ? "" : entry
> .getTitle().getPlainText()));
> // String name = entry.getName()!=
> // null?entry.getName().toString():"";
> // System.out.println(entry.getTitle().getPlainText()+"
> "+entry.getNickname()+" "+entry.getShortName()+" "+email.getDisplayName()+"
> "+email.getAddress());}
> }
> return contactList;
> }
>
> public static void main(String []args)throws IOException, ServiceException{
> List<Contact> contList = getConatacts("<email>@gmail.com", "<password>");
> for (Iterator iterator = contList.iterator(); iterator.hasNext();) {
> Contact contact = (Contact) iterator.next();
> System.out.println(contact.getTitle()+" "+contact.getEmail());
>
> }
> }
> }
>
> public class Contact {
> private String email;
> private String title;
> public Contact(String email, String title) {
> super();
> this.email = email;
> this.title = title;}
>
> public String getEmail() {
> return email;}
>
> public void setEmail(String email) {
> this.email = email;}
>
> public String getTitle() {
> return title;}
>
> public void setTitle(String title) {
> this.title = title;
>
> }
> }
>
> On Mon, Aug 2, 2010 at 4:05 PM, Ahmed Shoeib
> <[email protected]>wrote:
>
>
>
> > Hi All ,
>
> > i want to get  my gmail contacts and able to send message to anyone
> > of them
>
> > how i can do that ???
>
> > thanks for advance,
> > ahmed shoeib
> > java developer
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine for Java" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-appengine-java%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> Regards,
> Ravinder Singh Maan

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to