Getting Outlook Tasks in PowerShell is actually pretty easy. All you need to do is use the Office Interop to get access to the default tasks folder, then iterate through the items that are returned.
Create a file called Get-OutlookTask.ps1 in your scripts folder, and paste the following code:
Add-Type -AssemblyName Microsoft.Office.Interop.Outlook $folders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type] $outlook = New-Object -ComObject outlook.application $mapi = $outlook.GetNameSpace("mapi") $tasks = $mapi.getDefaultFolder($folders::olFolderTasks) foreach($task in $tasks.Items) { if(!$task.complete) { $task.subject } }
Naturally, you could customize this script to work any way you like – for example, you could sort by priorty or date, or you could show an extra column for category information. I have actually set up an alias to this script, so all I have to do is type tasks to see all my current tasks.
If you have set Vim to work with PowerShell, you can import your Outlook Tasks directly into the open document by using the Vim command:
:r! tasks
Pretty cool huh? If you’re looking to add Outlook Tasks in a similar way, you can check out this script by Lee Holmes. I use this one with the alias of nt to save on all that extra typing.
If you want to be able to add Outlook Tasks from Vim, I suggest you add the following function to your vimrc file:
function! Task(args) system("nt \\\"" . a:args . "\\\"") endfunction command! -nargs=1 Task :call Task('')
Now you just need to call :Task buy milk and it’ll get added – without switching to the shell itself.