---
title: "Codeunit 397 Mail"
author: "Jonas Paprotka"
url: https://jonas-paprotka.de/ref/codeunit/397-mail/
type: codeunit
id: 397
name: "Mail"
app: "Base Application"
namespace: System.EMail
versions: "17-28"
build: 28.5.54151.54365
source: "https://jonas-paprotka.de/ref/codeunit/397-mail/source/29/"
checked: 2026-09-20
subject: "Microsoft Dynamics 365 Business Central"
license: "Content © 2026 Jonas Paprotka. Quote freely with attribution and a link."
---

# Codeunit 397 Mail

Jonas Paprotka, https://jonas-paprotka.de/ref/codeunit/397-mail/

| | |
| --- | --- |
| App | Base Application |
| Namespace | System.EMail |
| Versions | 17-28 |
| Source file | OtherCapabilities/Email/Mail.Codeunit.al |

## Procedures

| Name | Parameters | Returns | Access | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- | --- |
| OpenNewMessage | (Text) | - | public | 17-28 | - | - |
| NewMessageAsync | (Text, Text, Text, Text, Text, Text, Boolean) | Boolean | public | 17-28 | - | - |
| NewMessage | (Text, Text, Text, Text, Text, Text, Boolean) | Boolean | public | 17-28 | - | - |
| CreateMessage | (Text, Text, Text, Text, Text, Boolean, Boolean) | - | public | 17-28 | - | - |
| AddBodyline | (Text) | Boolean | public | 17-24 | - | - |
| AttachFile | (Text) | - | public | 17-24 | - | - |
| Send | () | Boolean | public | 17-24 | - | - |
| GetErrorDesc | () | Text | public | 17-24 | - | - |
| CollectAddresses | (Code[20], var Record Communication Method, Boolean) | Text[260] | public | 17-28 | - | - |
| ValidateEmail | (var Record Communication Method, Text) | Boolean | public | 17-28 | - | - |
| TryInitializeOutlook | () | Boolean | public | 17-28 | - | - |
| CollectCurrentUserEmailAddresses | (var Record Name/Value Buffer) | - | public | 17-28 | - | - |
| FormatTextForHtml | (Text) | Text | public | 17-28 | - | - |

## Events

| Kind | Name | Parameters | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- |
| Integration event | OnGetEmailAddressFromActiveDirectory | (var Text, var Boolean) | 17-28 | - | - |
| Integration event | OnBeforeCreateMessage | (var Text, var Text, var Text, var Text, var Text) | 17-21 | - | - |
| Integration event | OnBeforeCreateAndSendMessage | (Text, Text, Text, Text, Text, Text, Boolean, var Boolean, var Boolean) | 17-28 | - | - |
| Integration event | OnCreateAndSendMessageOnAfterAttachFile | () | 19-28 | - | - |
| Integration event | OnBeforeCreateMessage | (var Text, var Text, var Text, var Text, var Text, Boolean, Boolean, var Boolean) | 22-28 | - | - |
| Integration event | OnCreateMessageOnBeforeClearAttachmentFileNames | (var Boolean) | 23-28 | - | - |
| Integration event | OnCollectCurrentUserEmailAddressesOnBeforeCheckIsSaaS | (var Record Name/Value Buffer) | 23-28 | - | - |

## Source

Symbols: Microsoft.BaseApplication.symbols.437dbf0e-84ff-417a-965d-ed2bb9650972, https://dynamicssmb2.pkgs.visualstudio.com/DynamicsBCPublicFeeds/_packaging/MSSymbols/nuget/v3/index.json, highest build per major on 2026-09-20.
AL source 29: https://github.com/microsoft/BCApps, MIT, releases/29.x at a66254c3b8b5bb1cea290dc8f9d097aec4381153.

Jonas Paprotka, 2026-09-20.
