README Create To Do Task #
What this does #
Creates a task in the signed-in user’s default To Do Tasks list — the same list visible in Microsoft To Do and the Tasks pane in Outlook. The endpoint used is POST /me/todo/lists/Tasks/tasks, where Tasks is a stable well-known alias for the default list. Authentication uses OAuth 2.0 with delegated permissions via VBAuth, supporting MFA. The task title is required; body/notes, due date, and importance level are optional.
Office apps #
- Access (tested M365)
- Excel (untested M365)
Required components #
- VBAuth.dll v1.x
- modVBAuthGlobalConstants.bas (from /shared)
- modCreateToDoTask.bas (this module)
Azure Entra App Registration #
Delegated permissions:
- Tasks.ReadWrite
Note: application permissions are not supported for this endpoint. Admin consent is required for Tasks.ReadWrite in most organisational tenants.
VBAuth Admin Table – Required Values #
| Column Name | Required Value / Example | Notes |
|---|---|---|
| AppID | 12 | Identifies this feature’s configuration record |
| ActionName | VBAuth – Create To Do Task | Display name — any value acceptable |
| ClientID | (your App Client ID) | GUID from Azure App Registration Overview blade |
| TenantID | (your Tenant ID) | GUID from Azure App Registration Overview blade |
| ObjectID | (your Object ID) | Set by PopulateMissingObjectIDs |
| ScopeClaims | Tasks.ReadWrite | Comma-separated Graph scopes |
| Verb | POST | HTTP method |
| URLPart1 | https://graph.microsoft.com/v1.0/me/todo/lists/Tasks/tasks | Graph endpoint |
| URLParameter1 | NO VALUE REQUIRED | Not used |
| URLPart2 | NO VALUE REQUIRED | Not used |
| URLParameter2 | NO VALUE REQUIRED | Not used |
| URLPart3 | NO VALUE REQUIRED | Not used |
| WaitForLogin | 60 | Seconds — NB MSXML2 timeout parameters are in milliseconds |
Module: modCreateToDoTask.bas #
Public functions #
Public Function CreateToDoTask( _
strTitle As String, _
strBody As String, _
strDueDate As String, _
strImportance As String, _
ByRef strMessage As String) As Boolean
Code language: JavaScript (javascript)
Sets intAppID = 12, loads configuration from lclVBAuthAdmin, acquires a bearer token for Tasks.ReadWrite, builds the JSON payload, and POSTs to /me/todo/lists/Tasks/tasks. Returns True on HTTP 201; returns False with a descriptive error in strMessage on any failure. strTitle is required; strBody, strDueDate, and strImportance may be passed as empty strings to omit them from the payload.
Private functions #
BuildCreateToDoTaskPayload — constructs the JSON request body. title is always included. body is serialised as an itemBody object with contentType: text. dueDateTime is serialised as a dateTimeTimeZone object with timeZone: UTC. importance is included as a plain string (low, normal, or high).
EscapeJsonString — escapes backslashes, double quotes, carriage returns, line feeds, and tabs for safe embedding in JSON string values.
Behaviour #
- Runs as the signed-in user (delegated flow) — the task is created in that user’s own default Tasks list.
- HTTP 201 Created is the success response. Any other status is treated as a failure and the full response body is returned in
strMessage. - The
Tasksalias in the URL resolves to the list withwellknownListName: defaultList— the list labelled “Tasks” in Outlook and Microsoft To Do. - Due date is accepted in
yyyy-MM-ddformat and sent to Graph as a UTC midnightdateTimeTimeZoneobject. - All string values passed to the payload builder are escaped through
EscapeJsonStringbefore serialisation. - An interactive browser sign-in is required on first use, or when the cached token has expired.
- HTTP timeouts use the
lngHTTPTimeoutglobal constant defined inmodVBAuthGlobalConstants.bas.
Notes #
- No application permissions —
Tasks.ReadWriteis delegated only. strBody,strDueDate, andstrImportanceare fully optional; pass""to omit each from the payload.- Admin consent for
Tasks.ReadWriteis typically required in organisational (work/school) tenants before users can authenticate. - The correct HTTP success code is 201 Created, not 200 OK.
- Tasks created via this endpoint appear immediately in Microsoft To Do and in the Outlook Tasks pane on all platforms.
VBAuth, developed and maintained by Andrew Richards (The IT Service Ltd) and Peter Bryant (Corylus Business Systems), © 2025–2026. All rights reserved. https://vbauth.com