Codeunit 8901 "Email"
System Application · System.Email
Across versions
- BC23present
- BC241 procedures added
- BC2511 procedures added, 2 events added
- BC261 events changed
- BC271 procedures added
- BC286 procedures added
- BC291 events added
- BC30unchanged
Neighbourhood 27 connected objects and pages
System Application · System.Email · BC23-30 · source at ea08af5e · facts from BC29
Properties
| Property | Value |
|---|---|
| Access | Public |
Events published
OnShowSource(SourceTableId: Integer; SourceSystemId: Guid; var IsHandled: Boolean)(integration): Integration event to show an email source record.- subscribers: Codeunit 8898 “Map Email Source” OnGetPageForSourceRecord
OnBeforeFilterRemovedSourceRecords(var EmailRelatedRecord: Record "Email Related Record")+ BC29 (integration): Integration event that allows applying additional filtering to related source records before they are shown.OnAfterAddRelation(EmailMessageId: Guid; TableId: Integer; SystemId: Guid; var RelatedSystemIds: Dictionary of [Integer, List of [Guid]])(integration): Integration event to add additional relations based on added relation to emails.- subscribers: Codeunit 5956 “Contact Business Relation” OnEmailAddedRelation
OnAfterRemoveRelation(EmailMessageId: Guid; TableId: Integer; SystemId: Guid)(integration): Integration event to execute code when relation is removed from email.OnGetBodyForTestEmail(Connector: Enum "Email Connector"; AccountId: Guid; var Body: Text)(integration): Integration event to override the default email body for test messages.- subscribers: Codeunit 4513 “SMTP Connector Impl.” SetTestEmailBody
OnFindRelatedAttachments(SourceTableId: Integer; SourceSystemID: Guid; var EmailRelatedAttachments: Record "Email Related Attachment")(integration): Integration event to get the names and IDs of attachments related to a source record.- subscribers: Codeunit 8898 “Map Email Source” FindRelatedAttachments
OnGetAttachment(AttachmentTableID: Integer; AttachmentSystemID: Guid; MessageID: Guid)(integration): Integration event that requests an attachment to be added to an email.- subscribers: Codeunit 8898 “Map Email Source” InsertAttachment
OnEnqueuedInOutbox(MessageId: Guid)(integration): Integration event to implement additional validation after the email message has been enqueued in the email outbox.OnEnqueuedReplyInOutbox(MessageId: Guid)+ BC25 (integration): Integration event to implement additional validation after the email message has been enqueued in the email outbox.OnAfterEmailSent(SentEmail: Record "Sent Email")(integration): Integration event that notifies senders when the email has been sent successfully. This event is isolated.OnAfterEmailSendFailed(EmailOutbox: Record "Email Outbox")(integration): Integration event that notifies senders when the email has been sent unsuccessfully. This event is isolated.- subscribers: Codeunit 6753 “Send Reminder Event Handler” UpdateAfterEmailSendFailed
OnBeforeOpenEmailEditor(var EmailMessage: Codeunit "Email Message"; IsNewEmail: Boolean)(integration): Integration event that allows updating of the email message before the email editor opens.OnBeforeSendEmail(var EmailMessage: Codeunit "Email Message")(integration): Integration event that allows updating of the email message before the email is queued for sending.OnBeforeReplyEmail(var EmailMessage: Codeunit "Email Message")+ BC25 (integration): Integration event that allows updating of the email message before the email is queued for replying.OnBeforeGetEmailAttachmentsByEmailScenarios(var EmailScenarioAttachments: Record "Email Scenario Attachments")Δ BC26 (integration): Integration event that allows adding filters to the Email Scenario Attachments before they are retrieved.
Procedures
SaveAsDraft(EmailMessage: Codeunit "Email Message"): Saves a draft email in the Outbox.SaveAsDraft(EmailMessage: Codeunit "Email Message"; var EmailOutbox: Record "Email Outbox"): Saves a draft email in the Outbox.SaveAsDraft(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailOutbox: Record "Email Outbox"): Saves a draft email in the Outbox.Enqueue(EmailMessage: Codeunit "Email Message"): Enqueues an email to be sent in the background.Enqueue(EmailMessage: Codeunit "Email Message"; NotBefore: DateTime): Enqueues an email to be sent in the background.Enqueue(EmailMessage: Codeunit "Email Message"; EmailScenario: Enum "Email Scenario"): Enqueues an email to be sent in the background.Enqueue(EmailMessage: Codeunit "Email Message"; EmailScenario: Enum "Email Scenario"; NotBefore: DateTime): Enqueues an email to be sent in the background.Enqueue(EmailMessage: Codeunit "Email Message"; EmailAccount: Record "Email Account" temporary): Enqueues an email to be sent in the background.Enqueue(EmailMessage: Codeunit "Email Message"; EmailAccount: Record "Email Account" temporary; NotBefore: DateTime): Enqueues an email to be sent in the background.Enqueue(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"): Enqueues an email to be sent in the background.Enqueue(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; NotBefore: DateTime): Enqueues an email to be sent in the background.Send(EmailMessage: Codeunit "Email Message"): Boolean: Sends the email in the current session.Send(EmailMessage: Codeunit "Email Message"; EmailScenario: Enum "Email Scenario"): Boolean: Sends the email in the current session.Send(EmailMessage: Codeunit "Email Message"; EmailAccount: Record "Email Account" temporary): Boolean: Sends the email in the current session.Send(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"): Boolean: Sends the email in the current session.Reply(EmailMessage: Codeunit "Email Message"; ExternalId: Text; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"): Boolean+ BC25 + BC25 (obsolete 26.0: Replaced by Reply without the ExternalId parameter. ExternalId is not used and is contained in the EmailMessage parameter.): Sends a reply to an external message id in the foreground.ReplyAll(EmailMessage: Codeunit "Email Message"; ExternalId: Text; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"): Boolean+ BC25 + BC25 (obsolete 26.0: Replaced by ReplyAll without the ExternalId parameter. ExternalId is not used and is contained in the EmailMessage parameter.): Sends a reply to an external message id to all recipients on that email in the foreground.EnqueueReply(EmailMessage: Codeunit "Email Message"; ExternalId: Text; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailOutbox: Record "Email Outbox")+ BC25 + BC25 (obsolete 26.0: Replaced by EnqueueReply without the ExternalId parameter. ExternalId is not used and is contained in the EmailMessage parameter.): Sends a reply to an external message id in the background.EnqueueReplyAll(EmailMessage: Codeunit "Email Message"; ExternalId: Text; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailOutbox: Record "Email Outbox")+ BC25 + BC25 (obsolete 26.0: Replaced by EnqueueReplyAll without the ExternalId parameter. ExternalId is not used and is contained in the EmailMessage parameter.): Sends a reply to an external message id to all recipients on that email in the foreground.Reply(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"): Boolean+ BC25 + BC25: Sends a reply to an external message id in the foreground.ReplyAll(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"): Boolean+ BC25 + BC25: Sends a reply to an external message id to all recipients on that email in the foreground.EnqueueReply(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailOutbox: Record "Email Outbox")+ BC25 + BC25: Sends a reply to an external message id in the background.EnqueueReplyAll(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailOutbox: Record "Email Outbox")+ BC25 + BC25: Sends a reply to an external message id to all recipients on that email in the foreground.RetrieveEmails(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailInbox: Record "Email Inbox")+ BC25 + BC25 (obsolete 26.0: Replaced by RetrieveEmails with an additional Filters parameter of type Record “Email Retrieval Filters”.): Retrieves emails from the email account.RetrieveEmails(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailInbox: Record "Email Inbox"; var Filters: Record "Email Retrieval Filters" temporary)+ BC25 + BC25: Retrieves emails from the email account.GetMailFolders(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailFolders: Record "Email Folders" temporary)+ BC27FindRetrievedEmail(EmailAccountId: Guid; ExternalMessageId: Text; var EmailInbox: Record "Email Inbox"): Boolean+ BC28: Finds an email that was previously retrieved into the email inbox for the given account.MarkAsRead(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; ExternalId: Text)+ BC25: Marks the specified email as read.GetEmailCategories(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; var EmailCategories: Record "Email Categories" temporary)+ BC28: Gets email categories from the specified email account.CreateEmailCategory(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; CategoryDisplayName: Text): Text+ BC28 + BC28: Creates a new email category in the specified email account.CreateEmailCategory(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; CategoryDisplayName: Text; CategoryColor: Text): Text+ BC28 + BC28: Creates a new email category with a specified color in the specified email account.ApplyEmailCategory(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; ExternalId: Text; CategoryDisplayName: Text)+ BC28 + BC28: Applies email categories to an email message.ApplyEmailCategory(EmailAccountId: Guid; EmailConnector: Enum "Email Connector"; ExternalId: Text; Categories: List of [Text])+ BC28 + BC28: Applies email categories to an email message.OpenInEditor(EmailMessage: Codeunit "Email Message"): Opens an email message in “Email Editor” page.OpenInEditor(EmailMessage: Codeunit "Email Message"; EmailScenario: Enum "Email Scenario"): Opens an email message in “Email Editor” page.OpenInEditor(EmailMessage: Codeunit "Email Message"; EmailAccount: Record "Email Account" temporary): Opens an email message in “Email Editor” page.OpenInEditor(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"): Opens an email message in “Email Editor” page.OpenInEditorModally(EmailMessage: Codeunit "Email Message"): Enum "Email Action": Opens an email message in “Email Editor” page modally.OpenInEditorModally(EmailMessage: Codeunit "Email Message"; EmailScenario: Enum "Email Scenario"): Enum "Email Action": Opens an email message in “Email Editor” page modally.OpenInEditorModallyWithScenario(EmailMessage: Codeunit "Email Message"; EmailAccount: Record "Email Account" temporary; Scenario: Enum "Email Scenario"): Enum "Email Action": Opens an email message in “Email Editor” page modally with scenario.OpenInEditorModally(EmailMessage: Codeunit "Email Message"; EmailAccount: Record "Email Account" temporary): Enum "Email Action": Opens an email message in “Email Editor” page modally.OpenInEditorModally(EmailMessage: Codeunit "Email Message"; EmailAccountId: Guid; EmailConnector: Enum "Email Connector"): Enum "Email Action": Opens an email message in “Email Editor” page modally.GetSentEmailsForRecord(TableId: Integer; SystemId: Guid; var ResultSentEmails: Record "Sent Email" temporary): Gets the sent emails related to a record.GetSentEmailsForRecord(RecordVariant: Variant; var ResultSentEmails: Record "Sent Email" temporary): Gets the sent emails related to a record.GetEmailOutboxForRecord(RecordVariant: Variant; var ResultEmailOutbox: Record "Email Outbox" temporary): Gets the outbox emails related to a record.OpenSentEmails(TableId: Integer; SystemId: Guid)+ BC24: Open the sent emails page for a source record given by its table ID and system ID.OpenSentEmails(RecordVariant: Variant)+ BC24: Open the sent emails page for a source record.OpenSentEmails(TableId: Integer; SystemId: Guid; NewerThanDate: DateTime)+ BC24: Open the sent emails page for a source record given by its table ID and system ID.GetOutboxEmailRecordStatus(MessageId: Guid): Enum "Email Status": Gets the outbox email status.AddRelation(EmailMessage: Codeunit "Email Message"; TableId: Integer; SystemId: Guid; RelationType: Enum "Email Relation Type"; Origin: Enum "Email Relation Origin"): Adds a relation between an email message and a record.RemoveRelation(EmailMessage: Codeunit "Email Message"; TableId: Integer; SystemId: Guid): Boolean: Removes a related record from an email message.HasRelations(EmailMessage: Codeunit "Email Message"): Boolean: Check if email has any related records linked.AddDefaultAttachments(EmailMessage: Codeunit "Email Message"; EmailScenario: Enum "Email Scenario"): Adds the default attachments of a scenario to the email message.
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 8900 “Email Impl” (25 calls:
AddDefaultAttachments → AddDefaultAttachments,AddRelation → AddRelation,ApplyEmailCategory → ApplyEmailCategory, …) - Codeunit 8904 “Email Message” (1 call:
HasRelations → GetId)
Called by
- Codeunit 8900 “Email Impl” (6 calls:
AddRelation → OnAfterAddRelation,BeforeReplyEmail → OnBeforeReplyEmail,BeforeSendEmail → OnBeforeSendEmail, …) - Codeunit 9520 “Mail Management” (5 calls:
SendViaEmailModule → AddDefaultAttachments,SendViaEmailModule → AddRelation,SendViaEmailModule → Enqueue, …) - Codeunit 8361 “Financial Report Export Job” (4 calls:
ExportPackageSchedule → AddRelation,ExportPackageSchedule → Send,ExportSchedule → AddRelation, …) - Codeunit 8906 “Email Editor” (4 calls:
AddRelatedRecordsFromEmailAddress → AddRelation,AddRelatedRecordsFromEmailAddress → HasRelations,AttachFromRelatedRecords → OnGetAttachment, …) - Codeunit 4582 “SOA Retrieve Emails” (3 calls:
AddEmailInboxToSOAEmails → ApplyEmailCategory,AddEmailInboxToSOAEmails → MarkAsRead,RetrieveEmails → RetrieveEmails) - Codeunit 4397 “SOA Test Setup” (2 calls:
EmailConnectionTest → RetrieveEmails,EmailCountTest → RetrieveEmails) - Codeunit 4419 “SOA Send Reply” (2 calls:
OnRun → Reply,OnRun → ReplyAll) - Codeunit 6940 “EA Retrieve Emails” (2 calls:
AddEmailInboxToEAEmails → MarkAsRead,RetrieveEmails → RetrieveEmails) - Codeunit 8887 “Email Test Mail” (2 calls:
OnRun → OnGetBodyForTestEmail,OnRun → Send) - Codeunit 8888 “Email Dispatcher” (2 calls:
SendEmail → OnAfterEmailSendFailed,SendEmail → OnAfterEmailSent) - Codeunit 8907 “Email Viewer” (2 calls:
EditAndSend → OpenInEditor,Resend → Enqueue) - Codeunit 1368 “Monitored Field Notification” (1 call:
SendEmail → Enqueue) - Codeunit 3309 “PA Demo Guide” (1 call:
SendDemoEmail → Send) - Codeunit 3310 “PA Validate Setup” (1 call:
OnRun → RetrieveEmails) - Codeunit 4509 “Email - Outlook API Helper” (1 call:
CreateEmailInboxFromJsonObject → FindRetrievedEmail) - Codeunit 6938 “EA Agent Dispatcher” (1 call:
SendEmail → Send) - Codeunit 6942 “EA Mailbox Access” (1 call:
AccessMailbox → RetrieveEmails) - Codeunit 8897 “Email Error Handler” (1 call:
OnRun → OnAfterEmailSendFailed) - Codeunit 8902 “Email Scenario Attach Impl.” (1 call:
GetEmailAttachmentsByEmailScenarios → OnBeforeGetEmailAttachmentsByEmailScenarios) - Page 4400 “SOA Setup” (1 call:
SetDefaultInboxFolder → GetMailFolders) - Page 4444 “Email Account Folders” (1 call:
OnOpenPage → GetMailFolders) - Page 9033 “Invite External Accountant” (1 call:
SendInvitationEmail → Send)
Recent changes
- 2026-09-21 #11612 Multiple runs of email retrieval on the same emails don’t persist again (main, BC30, fix)
- 2026-07-20 #8771 Add OnBeforeFilterRemovedSourceRecords integration event in Email Impl (main, BC30, feature)
Deprecations
- procedure EnqueueReply: Pending 26.0 (#if not CLEAN26), “Replaced by EnqueueReply without the ExternalId parameter. ExternalId is not used and is contained in the EmailMessage parameter.”
- procedure EnqueueReplyAll: Pending 26.0 (#if not CLEAN26), “Replaced by EnqueueReplyAll without the ExternalId parameter. ExternalId is not used and is contained in the EmailMessage parameter.”
- procedure Reply: Pending 26.0 (#if not CLEAN26), “Replaced by Reply without the ExternalId parameter. ExternalId is not used and is contained in the EmailMessage parameter.”
- procedure ReplyAll: Pending 26.0 (#if not CLEAN26), “Replaced by ReplyAll without the ExternalId parameter. ExternalId is not used and is contained in the EmailMessage parameter.”
- procedure RetrieveEmails: Pending 26.0 (#if not CLEAN26), “Replaced by RetrieveEmails with an additional Filters parameter of type Record “Email Retrieval Filters”.”
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"), then bcatlas_get_procedure_body or bcatlas_get_neighbors on the returned id.