README Create Task

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 NameRequired Value / ExampleNotes
AppID12Identifies this feature’s configuration record
ActionNameVBAuth – Create To Do TaskDisplay 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
ScopeClaimsTasks.ReadWriteComma-separated Graph scopes
VerbPOSTHTTP method
URLPart1https://graph.microsoft.com/v1.0/me/todo/lists/Tasks/tasksGraph endpoint
URLParameter1NO VALUE REQUIREDNot used
URLPart2NO VALUE REQUIREDNot used
URLParameter2NO VALUE REQUIREDNot used
URLPart3NO VALUE REQUIREDNot used
WaitForLogin60Seconds — 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 Tasks alias in the URL resolves to the list with wellknownListName: defaultList — the list labelled “Tasks” in Outlook and Microsoft To Do.
  • Due date is accepted in yyyy-MM-dd format and sent to Graph as a UTC midnight dateTimeTimeZone object.
  • All string values passed to the payload builder are escaped through EscapeJsonString before serialisation.
  • An interactive browser sign-in is required on first use, or when the cached token has expired.
  • HTTP timeouts use the lngHTTPTimeout global constant defined in modVBAuthGlobalConstants.bas.

Notes #

  • No application permissions — Tasks.ReadWrite is delegated only.
  • strBody, strDueDate, and strImportance are fully optional; pass "" to omit each from the payload.
  • Admin consent for Tasks.ReadWrite is 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

Updated on April 3, 2026