Get Tasks in Outlook 2007 with VB.NET

You can retrieve the list of tasks in your Outlook 2007 using the following code

Dim ns As Outlook.NameSpace
Dim tasks As Outlook.Items
ns = Application.GetNamespace(“MAPI”)
tasks = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Items

Dim task As Object
For Each task In tasks
    ‘ iterate through the tasks here
Next