Jul 162012
 

I’ve used this script to create a To-Do list based on the tasks I have in Outlook.

First up, we create the Outlook ActiveX Object

outlookApp = new ActiveXObject("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
nameSpace.logon("","",false,false);

Then we specify the default folder as the “Tasks” in Outlook

Tasks = nameSpace.getDefaultFolder(13);

Then we create the myTasks object from the items within the Outlook task list.

myTasks = Tasks.Items;

I have used a for loop here to go through all the tasks, however a while loop can also be used.
The first line gets the amount of tasks that exist, and then I create a variable to store all the tasks that I have, and then the for loop then goes through them all.

count = myTasks.Count;
result = '';
for(x = 1; x <= count; x++) { result += "-"+myTasks(x)+ "\n"; }

Now at the end I log off Outlook and clear all the variables.

nameSpace.logoff();
olLoggedOn = false;
nameSpace = null;
outlookApp = null;

Placing that code into a JScript file for execution from another program, e.g. Samurize, or creating a little HTML application will then allow you to look at your Outlook tasks without needing Outlook open.

If you have multiple categories which you want multiple lists for, you can restrict them using "Categories" property.
For example, if I only wanted Tasks that had the category of "blog", I could restrict it via the categories property.

myTasks = Tasks.Items;
myTasks.Restrict("[Categories] = blog");

The myTasks object will now only contain items that has the category blog.

The same can be done with the "Completed" flag

myTasks = Tasks.Items;
myTasks.Restrict("[Complete] = false");

Now the myTasks item will only contain items that aren't marked as completed.

Hopefully this helps someone out there !
Happy Coding !

Share

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)