RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Apply the New Vista APIs to Sidebar Gadgets, Part 2

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

eveloping Windows Vista Sidebar gadgets generally involves a lot of JavaScript programming. To make it possible for Sidebar gadgets to access the various systems' information, Microsoft has provided a set of APIs that Sidebar gadget developers can use within their Sidebar gadgets, which are callable from JavaScript. This series explores the various gadget objects and how they can be used enhance the functionality of your gadget. They're grouped based on their functionalities:
  • Contacts
  • Debugging and diagnostics
  • Sidebar gadgets UI
  • Machine information
  • Emails
  • Network
  • Sounds
  • Time and time zones
Part 1 covered the first four functionalities, and Part 2 will cover the last four.

Using Sidebar, you can access the email content of your Windows Mail (formerly known as Outlook Express) account using the following gadget objects:

  • System.MessageStore
  • System.MessageStoreFolder
  • System.MessageStoreMessage
The System.MessageStore object returns a collection of System.MessageStoreFolders objects. The following code prints out the various folders in Windows Mail (default email account):

         var result = document.getElementById("result");        

         //---get all the different folders in the mailbox---
         var folders = System.MessageStore.Folders;

         for (i=0; i<folders.count; i++)
            var folder = folders.item(i);
            result.innerHTML += "Name: " + folder.name + "<br/>";
Here's an example of the output:

Name: Inbox
Name: Outbox
Name: Sent Items
Name: Deleted Items
Name: Drafts
Name: Junk E-mail
Add the following code and you can print out the total number of messages contained within the folders—in addition to printing the folder names:

     result.innerHTML += "Name: " + folder.name + "<br/>";
     result.innerHTML += "Unread Messages: " + 
                         folder.unreadMessageCount + "<br/>";
     result.innerHTML += "Messages: " + folder.messageCount + "<br/>";
System.MessageStoreFolder and System.MessageStoreMessage
The System.MessageStoreFolder object returns a collection of System.MessageStoreMessage objects.

The code in Listing 1 prints out the content of all the messages contained in each folder.

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