---
id: object/codeunit/4509
type: object
title: Codeunit 4509 "Email - Outlook API Helper"
summary: Codeunit 4509 "Email - Outlook API Helper" in Email - Outlook REST API (System.Email). 25 public procedures, 4 events, 2 event subscribers. Introduced in BC29, still in BC30.
tier: official
language: en
tags:
  - codeunit
  - email - outlook rest api
versions:
  introduced: "29"
  last_changed: null
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 0eab0bdaeb6f925d518a93e232606957763a13f13edb9331742b7d4d0496dd33
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/Email%20-%20Outlook%20REST%20API/app/src/EmailOutlookAPIHelper.Codeunit.al
    title: src/Apps/W1/Email - Outlook REST API/app/src/EmailOutlookAPIHelper.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/11612
    - change/bcapps/9744
object_type: codeunit
object_id: 4509
name: Email - Outlook API Helper
namespace: System.Email
app: Email - Outlook REST API
extends: null
first_version: "29"
last_version: "30"
present_in:
  - "29"
  - "30"
changed_in: []
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 54
  events: 4
  subscribers: 2
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 7
  called_by: 5
  implements: 0
---

# Codeunit 4509 "Email - Outlook API Helper"

> Codeunit 4509 "Email - Outlook API Helper" in Email - Outlook REST API (System.Email). 25 public procedures, 4 events, 2 event subscribers. Introduced in BC29, still in BC30.

Email - Outlook REST API · System.Email · BC29-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/Email%20-%20Outlook%20REST%20API/app/src/EmailOutlookAPIHelper.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Permissions | tabledata "Email Inbox" = ri, tabledata "Email - Outlook Account" = rimd |

## Events published

- `OnAfterInitializeClientsV2(var OutlookAPIClient: interface "Email - Outlook API Client v2"; var OAuthClient: interface "Email - OAuth Client v2")` (internal)
- `OnAfterInitializeClientsV4(var OutlookAPIClient: interface "Email - Outlook API Client v4"; var OAuthClient: interface "Email - OAuth Client v2")` (internal)
- `OnAfterInitializeClientsV5(var OutlookAPIClient: interface "Email - Outlook API Client v5"; var OAuthClient: interface "Email - OAuth Client v2")` (internal)
- `OnAfterInitializeClientsV6(var OutlookAPIClient: interface "Email - Outlook API Client v6"; var OAuthClient: interface "Email - OAuth Client v2")` (internal)

## Event subscriptions

- OnDeleteOutlookAPIAccount subscribes to Table "Email - Outlook API Setup" OnBeforeDeleteEvent
- ClearCompanyConfigGeneral subscribes to Codeunit "Environment Cleanup" OnClearCompanyConfig

## Procedures

- `GetAccounts(Connector: Enum "Email Connector"; var Accounts: Record "Email Account")`
- `DeleteAccount(AccountId: Guid): Boolean`
- `EmailMessageToJson(EmailMessage: Codeunit "Email Message"; Account: Record "Email - Outlook Account"): JsonObject`
- `EmailMessageToReplyJson(EmailMessage: Codeunit "Email Message"; ReplyBody: Text; AsHtml: Boolean): JsonObject`
- `EmailMessageToJson(EmailMessage: Codeunit "Email Message"): JsonObject`
- `AddEmailAttachments(EmailMessage: Codeunit "Email Message"; var MessageJson: JsonObject)`
- `GetClientIDAndSecret(var ClientId: Text; var ClientSecret: SecretText)`
- `SetupAzureAppRegistration()`
- `GetRedirectURL(): Text`
- `IsAzureAppRegistrationSetup(): Boolean`
- `InitializeClients(var OutlookAPIClient: interface "Email - Outlook API Client v2"; var OAuthClient: interface "Email - OAuth Client v2")` (obsolete 28.0: Update OutlookAPIClient to v5.)
- `InitializeClients(var OutlookAPIClient: interface "Email - Outlook API Client v4"; var OAuthClient: interface "Email - OAuth Client v2")` (obsolete 28.0: Update OutlookAPIClient to v5.)
- `InitializeClients(var OutlookAPIClient: interface "Email - Outlook API Client v5"; var OAuthClient: interface "Email - OAuth Client v2")`
- `InitializeClients(var OutlookAPIClient: interface "Email - Outlook API Client v6"; var OAuthClient: interface "Email - OAuth Client v2")`
- `Send(EmailMessage: Codeunit "Email Message"; AccountId: Guid)`
- `Send(EmailMessage: Codeunit "Email Message")`
- `RetrieveEmails(AccountId: Guid; var EmailInbox: Record "Email Inbox")`
- `RetrieveEmails(AccountId: Guid; var EmailInbox: Record "Email Inbox"; var Filters: Record "Email Retrieval Filters")`
- `GetEmailFolders(AccountId: Guid; var EmailFolders: Record "Email Folders")`
- `MarkEmailAsRead(AccountId: Guid; ExternalMessageId: Text)`
- `GetEmailCategories(AccountId: Guid; var EmailCategories: Record "Email Categories" temporary)`
- `CreateEmailCategory(AccountId: Guid; CategoryDisplayName: Text; CategoryColor: Text): Text`
- `ApplyEmailCategory(AccountId: Guid; ExternalId: Text; Categories: List of [Text])`
- `ReplyEmail(AccountId: Guid; var EmailMessage: Codeunit "Email Message")`
- `DefaultEmailRateLimit(): Integer`

Plus 23 local procedures.

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 8904 "Email Message"](../codeunit/8904.md) (18 calls: `AddAttachmentsToMessage → AddAttachment`, `AddEmailAttachments → Attachments_First`, `AddEmailAttachments → Attachments_GetContentBase64`, …)
- [Codeunit 4100 "Temp Blob"](../codeunit/4100.md) (2 calls: `AddAttachmentsToMessage → CreateInStream`, `AddAttachmentsToMessage → CreateOutStream`)
- [Codeunit 457 "Environment Information"](../codeunit/457.md) (2 calls: `GetClientIDAndSecret → IsSaaSInfrastructure`, `SetupAzureAppRegistration → IsSaaSInfrastructure`)
- [Codeunit 8894 "Email Account"](../codeunit/8894.md) (2 calls: `EmailOutlookAccountAddressValidation → ValidateEmailAddress`, `GetEmailAddressFromEmailAccounts → GetAllAccounts`)
- [Codeunit 4110 "Base64 Convert"](../codeunit/4110.md) (1 call: `AddAttachmentsToMessage → FromBase64`)
- [Codeunit 8901 "Email"](../codeunit/8901.md) (1 call: `CreateEmailInboxFromJsonObject → FindRetrievedEmail`)
- [Page 4509 "Email - Outlook API Setup"](../page/4509.md) (1 call: `SetupAzureAppRegistration → (object)`)

## Called by

- [Codeunit 4500 "Current User Connector"](../codeunit/4500.md) (14 calls: `ApplyEmailCategory → ApplyEmailCategory`, `CreateEmailCategory → CreateEmailCategory`, `DeleteAccount → DeleteAccount`, …)
- [Codeunit 4503 "Microsoft 365 Connector"](../codeunit/4503.md) (12 calls: `ApplyEmailCategory → ApplyEmailCategory`, `CreateEmailCategory → CreateEmailCategory`, `DeleteAccount → DeleteAccount`, …)
- [Codeunit 4507 "Email - OAuth Client"](../codeunit/4507.md) (2 calls: `Initialize → GetClientIDAndSecret`, `Initialize → GetRedirectURL`)
- [Page 4500 "Current User Email Account"](../page/4500.md) (1 call: `OnOpenPage → GetAccounts`)
- [Page 4509 "Email - Outlook API Setup"](../page/4509.md) (1 call: `OnOpenPage → IsAzureAppRegistrationSetup`)

## Recent changes

- 2026-09-21 [#11612 Multiple runs of email retrieval on the same emails don't persist again](../../changes/bcapps/11612.md) (main, BC30, fix)
- 2026-07-29 [#9744 [Email - Outlook REST API] Skip attachments without contentBytes in RetrieveEmails](../../changes/bcapps/9744.md) (main, BC30, fix)

## Across versions

- Present in: BC29-30
- Changed (declaration) in: none

## Deprecations

- procedure OnAfterInitializeClientsV2: guarded (#if not CLEAN28)
- procedure OnAfterInitializeClientsV4: guarded (#if not CLEAN28)
- procedure InitializeClients: Pending 28.0 (#if not CLEAN28), "Update OutlookAPIClient to v5."
- procedure InitializeClients: Pending 28.0 (#if not CLEAN28), "Update OutlookAPIClient to v5."

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Email - Outlook API Helper")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
