---
id: object/codeunit/8905
type: object
title: Codeunit 8905 "Email Message Impl."
summary: Codeunit 8905 "Email Message Impl." in System Application (System.Email). 62 public procedures, 1 events, 10 event subscribers. Present since at least BC23, still in BC30, changed in BC24-28.
tier: official
language: en
tags:
  - codeunit
  - system application
versions:
  introduced: null
  last_changed: "28"
  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: 243963793830fd6f56ccf8849e7e850c74c88ddd2c929e515eea2a703ec0c869
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Email/src/Message/EmailMessageImpl.Codeunit.al
    title: src/System Application/App/Email/src/Message/EmailMessageImpl.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
object_type: codeunit
object_id: 8905
name: Email Message Impl.
namespace: System.Email
app: System Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 92
  events: 1
  subscribers: 10
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 1
  calls: 5
  called_by: 8
  implements: 0
---

# Codeunit 8905 "Email Message Impl."

> Codeunit 8905 "Email Message Impl." in System Application (System.Email). 62 public procedures, 1 events, 10 event subscribers. Present since at least BC23, still in BC30, changed in BC24-28.

System Application · System.Email · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/Email/src/Message/EmailMessageImpl.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Internal |
| Permissions | tabledata "Sent Email" = r, tabledata "Email Inbox" = r, tabledata "Email Outbox" = rim, tabledata "Email Message" = rimd, tabledata "Email Error" = rd, tabledata "Email Recipient" = rid, tabledata "Email Message Attachment" = rimd, tabledata "Email Related Record" = rd, tabledata "Tenant Media" = r... |

## Events published

- `OnBeforeDeleteSentEmailAttachment(var BypassSentCheck: Boolean)` (internal)
  - subscribers: [Codeunit 8865 "Email Attachments Impl"](../codeunit/8865.md) OnBeforeDeleteSentEmailAttachment

## Event subscriptions

- OnBeforeInsertEventEmailInbox subscribes to Table "Email Inbox" OnBeforeInsertEvent
- OnAfterDeleteEmailInbox subscribes to Table "Email Inbox" OnAfterDeleteEvent
- OnAfterDeleteSentEmail subscribes to Table "Sent Email" OnAfterDeleteEvent
- OnAfterDeleteEmailOutbox subscribes to Table "Email Outbox" OnAfterDeleteEvent
- OnBeforeDeleteEmailMessage subscribes to Table "Email Message" OnBeforeDeleteEvent
- OnBeforeModifyEmailMessage subscribes to Table "Email Message" OnBeforeModifyEvent
- OnBeforeDeleteAttachment subscribes to Table "Email Message Attachment" OnBeforeDeleteEvent
- OnBeforeDeleteRecipient subscribes to Table "Email Recipient" OnBeforeDeleteEvent
- OnBeforeInsertAttachment subscribes to Table "Email Message Attachment" OnBeforeInsertEvent
- OnBeforeInsertRecipient subscribes to Table "Email Recipient" OnBeforeInsertEvent

## Procedures

- `Create(EmailMessageImpl: Codeunit "Email Message Impl.")`
- `Create(ToRecipients: Text; Subject: Text; Body: Text; HtmlFormatted: Boolean)`
- `Create(ToRecipients: Text; Subject: Text; Body: Text; HtmlFormatted: Boolean; Sanitize: Boolean)`
- `Create(Recipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean; CCRecipients: List of [Text]; BCCRecipients: List of [Text]; Sanitize: Boolean)`
- `CreateReply(ToRecipients: Text; Subject: Text; Body: Text; HtmlFormatted: Boolean; ExternalId: Text)`
- `CreateReply(ToRecipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean; ExternalId: Text; CCRecipients: List of [Text]; BCCRecipients: List of [Text])`
- `CreateReplyAll(Subject: Text; Body: Text; HtmlFormatted: Boolean; ExternalId: Text)`
- `UpdateMessage(ToRecipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean; ExternalId: Text; CCRecipients: List of [Text]; BCCRecipients: List of [Text]; Sanitize: Boolean)`
- `Modify()`
- `GetBody(): Text`
- `SetBody(BodyText: Text)`
- `AppendToBody(BodyText: Text)`
- `GetExternalId(): Text[2048]`
- `GetSubject(): Text[2048]`
- `SetSubject(Subject: Text)`
- `IsBodyHTMLFormatted(): Boolean`
- `SetBodyHTMLFormatted(Value: Boolean)`
- `AddHeader(HeaderName: Text; HeaderValue: Text)`
- `SetHeader(HeaderName: Text; HeaderValue: Text)`
- `GetHeader(HeaderName: Text; var Value: Text): Boolean`
- `FlushHeaders()`
- `IsRead(): Boolean`
- `GetContentTypeFromFilename(FileName: Text): Text[250]`
- `AddAttachment(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentBase64: Text)`
- `AddAttachment(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentInStream: InStream)`
- `AddAttachment(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentInStream: InStream; InLine: Boolean; ContentId: Text[40])`
- `AddAttachment(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentInStream: InStream; InLine: Boolean; ContentId: Text[40]; MessageAlreadyRetrieved: Boolean)`
- `AddAttachmentInternal(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentInStream: InStream): Integer`
- `AddAttachmentInternal(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentInStream: InStream; InLine: Boolean; ContentId: Text[40]): Integer`
- `AddAttachmentInternal(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentInStream: InStream; InLine: Boolean; ContentId: Text[40]; MessageAlreadyRetrieved: Boolean): Integer`
- `AddAttachmentsFromScenario(var EmailAttachments: Record "Email Attachments")`
- `GetRecipients(): List of [Text]`
- `GetRecipients(RecipientType: Enum "Email Recipient Type"): List of [Text]`
- `GetRecipientsAsText(RecipientType: Enum "Email Recipient Type"): Text`
- `SetRecipients(RecipientType: Enum "Email Recipient Type"; RecipientsText: Text)`
- `SetRecipients(RecipientType: Enum "Email Recipient Type"; Recipients: List of [Text])`
- `AddRecipient(RecipientType: Enum "Email Recipient Type"; Recipient: Text)`
- `Attachments_DeleteContent(): Boolean`
- `Attachments_DeleteContent(BypassSentCheck: Boolean): Boolean`
- `Attachments_Delete(): Boolean`
- `Attachments_Delete(BypassSentCheck: Boolean): Boolean`
- `Attachments_First(): Boolean`
- `Attachments_Next(): Integer`
- `Attachments_GetId(): BigInteger`
- `Attachments_GetName(): Text[250]`
- `Attachments_GetContent(var InStream: InStream)`
- `Attachments_GetContentBase64(): Text`
- `Attachments_GetContentType(): Text[250]`
- `Attachments_GetContentId(): Text[40]`
- `Attachments_IsInline(): Boolean`
- `Attachments_GetLength(): Integer`
- `GetRelatedAttachments(var EmailRelatedAttachments: Record "Email Related Attachment"): Boolean`
- `GetRelatedAttachments(EmailMessageId: Guid; var EmailRelatedAttachmentOut: Record "Email Related Attachment"): Boolean`
- `GetId(): Guid`
- `Get(MessageId: Guid): Boolean`
- `DeleteOrphanedMessages(StartMessageId: Guid; MessagesToIterate: Integer): Guid`
- `DeleteEmailRecipientsIfOrphaned(StartMessageId: Guid; RecipientsToIterate: Integer): Guid`
- `ValidateRecipients()`
- `GetNoOfModifies(): Integer`
- `FormatFileSize(SizeInBytes: Integer): Text` (internal)
- `MarkAsRead()`
- `GetEmailMessage(var EmailMessage: Record "Email Message")`

Plus 19 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 4100 "Temp Blob"](../codeunit/4100.md) (4 calls: `AddAttachment → CreateInStream`, `AddAttachment → CreateOutStream`, `InsertAttachmentsFromScenario → CreateInStream`, …)
- [Codeunit 4110 "Base64 Convert"](../codeunit/4110.md) (2 calls: `AddAttachment → FromBase64`, `Attachments_GetContentBase64 → ToBase64`)
- [Codeunit 8894 "Email Account"](../codeunit/8894.md) (1 call: `ValidateRecipients → ValidateEmailAddress`)
- [Codeunit 8900 "Email Impl"](../codeunit/8900.md) (1 call: `Create → AddRelation`)
- [Codeunit 8904 "Email Message"](../codeunit/8904.md) (1 call: `Attachments_GetContent → OnGetAttachmentContent`)

## Called by

- [Codeunit 8904 "Email Message"](../codeunit/8904.md) (38 calls: `AddAttachment → AddAttachment`, `AddAttachmentFromScenario → AddAttachmentsFromScenario`, `AddHeader → AddHeader`, …)
- [Codeunit 8906 "Email Editor"](../codeunit/8906.md) (13 calls: `AttachFromWordTemplate → AddAttachmentInternal`, `AttachFromWordTemplate → GetContentTypeFromFilename`, `GetEmailMessage → Create`, …)
- [Codeunit 8888 "Email Dispatcher"](../codeunit/8888.md) (8 calls: `LogAttachments → Attachments_First`, `LogAttachments → Attachments_GetContentType`, `LogAttachments → Attachments_GetLength`, …)
- [Codeunit 8907 "Email Viewer"](../codeunit/8907.md) (5 calls: `EditAndSend → Create`, `EditAndSend → GetId`, `GetEmailMessage → Get`, …)
- [Page 12 "Email Viewer"](../page/12.md) (5 calls: `OnAfterGetRecord → Attachments_First`, `OnAfterGetRecord → GetBody`, `OnAfterGetRecord → GetRecipientsAsText`, …)
- [Codeunit 8900 "Email Impl"](../codeunit/8900.md) (4 calls: `OpenInEditorWithScenario → Get`, `OpenInEditorWithScenario → GetId`, `OpenInEditorWithScenario → GetSubject`, …)
- [Page 13 "Email Editor"](../page/13.md) (4 calls: `OnAfterGetRecord → GetBody`, `OnAfterGetRecord → GetRecipientsAsText`, `OnAfterGetRecord → GetSubject`, …)
- [Page 8889 "Email Attachments"](../page/8889.md) (2 calls: `OnAfterGetRecord → FormatFileSize`, `UpdateValues → GetId`)

## 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)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24-28

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