Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Apply the New Vista APIs to Sidebar Gadgets, Part 1  : Page 2

Explore the various Windows Vista Sidebar gadget objects and how they can be used to enhance the functionality of your gadget.


advertisement

WEBINAR:

On-Demand

Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js


Contacts
To access the contacts information stored in Windows Contacts (Start—>Programs—>Windows Contacts), you can use the following objects:
  • System.ContactManager
  • System.Contact

The System.ContactManager Object
This object exposes a collection of System.Contact objects through its Contacts collection. The following code gets all the contacts (located in C:\Users\<User_Name>\Contacts) and passes it to the contacts variable:

//---get all contacts--- var contacts = System.ContactManager.Contacts;

To access each contact individually, you can use its item property (zero-based):


//---get a particular contact (first contact)--- var contact = System.ContactManager.Contacts.item(0);

The count property provides the number of contacts retrieved:

//---get a particular contact (first contact)--- var count = System.ContactManager.Contacts.count;

The System.Contact Object
This object contains all the details of a contact. The following code shows how to retrieve all the contacts on the local computer and then prints out the details of each individual contact:

//---get all contacts--- var contacts = System.ContactManager.Contacts; var result = document.getElementById("result"); result.innerHTML = ""; //---print the details for each contact--- for (i=0; i<contacts.count; i++) { result.innerHTML += "<b>" + contacts.item(i).name + "</b><br/>"; result.innerHTML += contacts.item(i).city + "<br/>"; result.innerHTML += contacts.item(i).country + "<br/>"; result.innerHTML += contacts.item(i).defaultEmail + "<br/>"; result.innerHTML += contacts.item(i).filePath + "<br/>"; result.innerHTML += contacts.item(i).homePhone + "<br/>"; result.innerHTML += contacts.item(i).mobilePhone + "<br/>"; result.innerHTML += contacts.item(i).POBox + "<br/>"; result.innerHTML += contacts.item(i).postalCode + "<br/>"; result.innerHTML += contacts.item(i).state + "<br/>"; result.innerHTML += contacts.item(i).street + "<br/>"; result.innerHTML += contacts.item(i).workPhone + "<br/>"; }



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date