---
id: object/codeunit/397
type: object
title: Codeunit 397 "Mail"
summary: Codeunit 397 "Mail" in Base Application (System.Email). 9 public procedures, 6 events. Present since at least BC23, still in BC30, changed in BC25.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "25"
  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: 583a2023e5d7d0e60bd1d57b1e092813e8fba582ab64b79dd573c69474dbb09b
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/OtherCapabilities/Email/Mail.Codeunit.al
    title: src/Layers/W1/BaseApp/OtherCapabilities/Email/Mail.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 397
name: Mail
namespace: System.Email
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "25"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 26
  events: 6
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 4
  called_by: 1
  implements: 0
---

# Codeunit 397 "Mail"

> Codeunit 397 "Mail" in Base Application (System.Email). 9 public procedures, 6 events. Present since at least BC23, still in BC30, changed in BC25.

Base Application · System.Email · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/OtherCapabilities/Email/Mail.Codeunit.al) · facts from BC29

## Events published

- `OnGetEmailAddressFromActiveDirectory(var Email: Text; var Handled: Boolean)` (integration)
- `OnBeforeCreateMessage(var ToAddresses: Text; var CcAddresses: Text; var BccAddresses: Text; var Subject: Text; var Body: Text; ShowNewMailDialogOnSend: Boolean; RunModal: Boolean; var IsHandled: Boolean)` (integration)
- `OnBeforeCreateAndSendMessage(ToAddresses: Text; CcAddresses: Text; BccAddresses: Text; Subject: Text; Body: Text; AttachFilename: Text; ShowNewMailDialogOnSend: Boolean; var MailSent: Boolean; var IsHandled: Boolean)` (integration)
- `OnCreateAndSendMessageOnAfterAttachFile()` (integration)
- `OnCreateMessageOnBeforeClearAttachmentFileNames(var IsHandled: Boolean)` (integration)
- `OnCollectCurrentUserEmailAddressesOnBeforeCheckIsSaaS(var TempNameValueBuffer: Record "Name/Value Buffer" temporary)` (integration)

## Procedures

- `OpenNewMessage(ToName: Text)`
- `NewMessageAsync(ToAddresses: Text; CcAddresses: Text; BccAddresses: Text; Subject: Text; Body: Text; AttachFilename: Text; ShowNewMailDialogOnSend: Boolean): Boolean`
- `NewMessage(ToAddresses: Text; CcAddresses: Text; BccAddresses: Text; Subject: Text; Body: Text; AttachFilename: Text; ShowNewMailDialogOnSend: Boolean): Boolean`
- `CreateMessage(ToAddresses: Text; CcAddresses: Text; BccAddresses: Text; Subject: Text; Body: Text; ShowNewMailDialogOnSend: Boolean; RunModal: Boolean)`
- `CollectAddresses(ContactNo: Code[20]; var ContactThrough: Record "Communication Method"; ShowAddresses: Boolean): Text[260]`
- `ValidateEmail(var ContactThrough: Record "Communication Method"; EMailToValidate: Text): Boolean`
- `TryInitializeOutlook(): Boolean`
- `CollectCurrentUserEmailAddresses(var TempNameValueBuffer: Record "Name/Value Buffer" temporary)`
- `FormatTextForHtml(Text: Text): Text`

Plus 11 local procedures.

## Triggers

OnRun

## 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 4030 "Client Type Management"](../codeunit/4030.md) (1 call: `GetEmailAddressFromActiveDirectory → GetCurrentClientType`)
- [Codeunit 457 "Environment Information"](../codeunit/457.md) (1 call: `CollectCurrentUserEmailAddresses → IsSaaS`)
- [Codeunit 8893 "Email Scenario"](../codeunit/8893.md) (1 call: `GetDefaultScenarioEmailAddress → GetEmailAccount`)
- [Page 5145 "Contact Through"](../page/5145.md) (1 call: `CollectAddresses → (object)`)

## Called by

- [Table 5080 "To-do"](../table/5080.md) (1 call: `ProcessAttendeeAppointment → NewMessage`)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC25

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: "Mail")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
