Microsoft ToDo taskmanager

Hello, anyone aware of any scripts that work with MS ToDo?

I’m did some digging and the fact is that there is no Microsoft To Do AppleScript dictionary, but you can create tasks using Microsoft Outlook AppleScript. I have changed the default Add as To Do to Reminders so it talks to Microsoft Outlook tasks (so you will need to have that installed. Outlook syncs to Microsoft To Do, so after a short amount of time the task will appear in MS To Do.

You can add the script in the DT scripts location and use it from there. I did this very quick, so you need to do some testing :slight_smile:

-- Set properties
property pDaysIntoFuture : -1 -- Created to do will have a due date n days in the future
property pPrefix : "Reminder" -- Prefix for the created to do item
property pDelays : {{displayname:"No due date", value:0}, {displayname:"Custom…", value:-1}, {displayname:"Tomorrow", value:1 * days}, {displayname:"In two days", value:2 * days}, {displayname:"In three days", value:3 * days}, {displayname:"In one week", value:1 * weeks}, {displayname:"In two weeks", value:2 * weeks}, {displayname:"In one month", value:4 * weeks}, {displayname:"In two months", value:8 * weeks}, {displayname:"In three months", value:90 * days}, {displayname:"In six months", value:180 * days}, {displayname:"In one year", value:365 * days}}
property pDefaultDelay : "In one week"

set theDueDate to ""

-- Import helper library
tell application "Finder" to set pathToAdditions to ((path to application id "DNtp" as string) & "Contents:Resources:Template Script Additions.scpt") as alias
set helperLibrary to load script pathToAdditions

	-- Get the selection
	tell application id "DNtp" to set thisSelection to the selection
	-- Error handling
	if thisSelection is {} then error localized string "Please select a document or group, the try again."
	if (length of thisSelection) > 1 then error localized string "Please select only one document or group, then try again."
	-- Get and format the data we need
	set pLocalizedPrefix to localized string pPrefix
	tell application id "DNtp"
		set thisItem to first item of thisSelection
		set theSummary to (pLocalizedPrefix & ": " & name of thisItem) as string
		set theURL to (reference URL of thisItem) as string
	end tell
	-- Let the user choose the reminder list
	tell application "Microsoft Outlook"
		set theListNames to {}
		repeat with theList in the task folders
			set theListNames to theListNames & {name of theList}
		end repeat
	end tell
	if (count of theListNames) = 0 then error (localized string "Please set up at least one list in To Do.")
	set theChoice to choose from list theListNames with title (localized string "Choose list") default items {item 1 of theListNames}
	if theChoice is false then return false -- If the user pressed Cancel, exit
	if theChoice is missing value or class of item 1 of theChoice is not text then return false
	set theChosenListName to item 1 of theChoice
	-- Let the user choose when to receive the reminder
	-- Convert array into localized arrays
	set pLocalizedDelays to {}
	set pLocalizedDelayNames to {}
	repeat with theDelay in pDelays
		set pLocalizedDelays to pLocalizedDelays & {{displayname:localized string (displayname of theDelay), value:(value of theDelay)}}
		set pLocalizedDelayNames to pLocalizedDelayNames & {localized string (displayname of theDelay)}
	end repeat
	set theChoice to choose from list pLocalizedDelayNames with title (localized string "Set reminder") with prompt (localized string "Please choose when you want to get reminded of the item") & " \"" & theSummary & "\"" & (localized string "%choice prompt end%") & ":" default items {localized string pDefaultDelay}
	if theChoice is false then return false -- If the user pressed Cancel, exit
	set theDelayValue to pDaysIntoFuture -- Assume default
		-- Find the number of days associated with the user's choice
		repeat with theDelay in pLocalizedDelays
			if ((displayname of theDelay) as string) is equal to (theChoice as string) then set theDelayValue to (value of theDelay)
		end repeat
	end try
	-- Calculate due date
	if theDelayValue > 0 then
		set theDueDate to (date (date string of (current date))) + theDelayValue
	else if theDelayValue < 0 then
			set theDueDate to (date (text returned of (display dialog (localized string "Enter the due date") & ":" & return & (localized string "Example: 1/1/2017 10:45pm") default answer "")))
		on error
		end try
	end if
	-- Add new to do to Microsoft To Do
	tell application "Microsoft Outlook"
		set myList to task folder theChosenListName
		tell myList
			make new task with properties {name:theSummary, content:theURL, due date:theDueDate}
		end tell
	end tell
	-- Add new to do to Reminders
	-- tell application "Reminders"
	--	tell list theChosenListName
	--		--Create new to do
	--		if theDueDate ≠ "" then
	--			set theEvent to make reminder with properties {name:theSummary, remind me date:theDueDate, body:theURL}
	--		else
	--			set theEvent to make reminder with properties {name:theSummary, body:theURL}
	--		end if
	--		show theEvent -- Show new to do item in Reminders so that the user can edit it right away
	--		activate
	--	end tell
	-- end tell
on error errMsg
	display alert (localized string "Error when adding item to Reminders") message errMsg
end try

Thank you for the quick response! I will give this a go :slight_smile:

Thank you, it all works :slight_smile: Strangely when it asks for your list selection it is bringing back lots of old lists not just the ones currently listed in the app? Any idea how to filter out the old ones?

I noticed a lot of extra lists also, I’ll see if I can find a way to filter them. I personally do not use MS To Do, but I find these integrations interesting as I’m in a Microsoft word in my day-job.

I really appreciate it. I’m trying a few different ways of managing tasks - MS ToDo has the advantage of integrating flagged work emails.

I always create task from e-mails en do not use flagging. Some email contain more than one task and i like my tasks to have an actionable description… which many email do not have. I’m currently trying a working where every e-mail that is actionable is moved/copied to DT and a task is created from the item in DT.

This way my e-mailclient is just for receiving and replying to e-mail, I do not use it for archiving.

Interesting - what task manager do you use or how do you manage then in DT? I’ve used tags and smart searches etc, but finding that I need to “surface” the detail beyond the note title.