Codeunit 8904 "Email Message"
System Application · System.Email
Across versions
- BC23present
- BC241 procedures added
- BC256 procedures added
- BC261 procedures added
- BC271 procedures added
- BC285 procedures added
- BC29-30unchanged
Neighbourhood 23 connected objects and pages
System Application · System.Email · BC23-30 · source at ea08af5e · facts from BC29
Properties
| Property | Value |
|---|---|
| Access | Public |
Events published
OnGetAttachmentContent(MediaID: Guid; var InStream: InStream; var Handled: Boolean)(integration): Integration event to provide the stream of data for a given MediaID. If attachment content has been deleted, this event makes it possible to provide the data from elsewhere.
Procedures
Create(ToRecipients: Text; Subject: Text; Body: Text)+ BC25: Creates the email with recipients, subject, and body.Create(ToRecipients: Text; Subject: Text; Body: Text; HtmlFormatted: Boolean)+ BC25: Creates the email with recipients, subject, and body.Create(ToRecipients: Text; Subject: Text; Body: Text; HtmlFormatted: Boolean; Sanitize: Boolean)+ BC25: Creates the email with recipients, subject, and body.Create(ToRecipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean)+ BC25: Creates the email with recipients, subject, and body.Create(ToRecipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean; CCRecipients: List of [Text]; BCCRecipients: List of [Text])+ BC25: Creates the email with recipients, subject, and body.CreateReply(ToRecipients: Text; Subject: Text; Body: Text; HtmlFormatted: Boolean; ExternalId: Text)+ BC25 + BC25 + BC25: Creates the email reply with recipients, subject, and body.CreateReply(ToRecipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean; ExternalId: Text)+ BC25 + BC25 + BC25: Creates the email reply with recipients, subject, and body.CreateReply(ToRecipients: List of [Text]; Subject: Text; Body: Text; HtmlFormatted: Boolean; ExternalId: Text; CCRecipients: List of [Text]; BCCRecipients: List of [Text])+ BC25 + BC25 + BC25: Creates the email reply with recipients, subject, and body.CreateReplyAll(Subject: Text; Body: Text; HtmlFormatted: Boolean; ExternalId: Text)+ BC25: Creates the email replying to all existing recipents on the mail thread, subject, and body.Get(MessageId: Guid): Boolean: Gets the email message with the given ID.DeleteOrphanedMessages(StartMessageId: Guid; MessagesToIterate: Integer): Guid+ BC24: Deletes messages that does not have a reference from either the email outbox nor sent email. This functionality is only needed if email messages have been created without any email outbox or sent email referencing it, otherwise they will be cleaned up automatically.DeleteEmailRecipientsIfOrphaned(StartMessageId: Guid; MessagesToIterate: Integer): Guid+ BC27: Deletes email recipients that do not have a reference from email message. This functionality is only needed if email recipients have been created without any email message referencing it, otherwise they will be cleaned up automatically.GetBody(): Text: Gets the body of the email message.SetBody(Body: Text): Sets the body of the email message.AppendToBody(Value: Text): Appends to the body of the email message. The value to append to the body of the email message.AddHeader(HeaderName: Text; HeaderValue: Text)+ BC28: Adds a header to the currently loaded message. If a header with the same name is already present, the new value is appended after a line feed character so the full sequence is preserved – useful for headers that legitimately repeat (e.g. Received ).SetHeader(HeaderName: Text; HeaderValue: Text)+ BC28: Sets a header on the currently loaded message, replacing any existing value for the same name. Use when repeated headers should accumulate.GetHeader(HeaderName: Text; var Value: Text): Boolean+ BC28: Reads a single header value from the currently loaded message. Lookups are case-insensitive on the header name. Repeated headers are returned as one string with values joined by a line feed character in the order they were added.FlushHeaders()+ BC28: Persists any pending header mutations to the database in a single write. Safe to call when nothing is pending. Call this after any sequence of / calls so the changes survive the codeunit instance going out of scope or a subsequent navigation to another message.GetExternalId(): Text[2048]+ BC25GetSubject(): Text[2048]: Gets the subject of the email message.SetSubject(Subject: Text): Sets the subject of the email message.IsBodyHTMLFormatted(): Boolean: Checks if the email body is formatted in HTML.SetBodyHTMLFormatted(Value: Boolean): Sets whether the email body is formatted in HTML. True if the email body is formatted in HTML; otherwise - false.GetId(): Guid: Gets the ID of the email message.GetRecipients(RecipientType: Enum "Email Recipient Type"; var Recipients: List of [Text]): Gets the recipents of a certain type of the email message.SetRecipients(RecipientType: Enum "Email Recipient Type"; Recipients: Text): Sets the recipents of a certain type of the email message.SetRecipients(RecipientType: Enum "Email Recipient Type"; Recipients: List of [Text]): Sets the recipents of a certain type of the email message.AddRecipient(RecipientType: Enum "Email Recipient Type"; Recipient: Text): Adds a recipient of a certain type to the email message.AddAttachment(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentBase64: Text)+ BC28: Adds a file attachment to the email message.AddAttachment(AttachmentName: Text[250]; ContentType: Text[250]; AttachmentInStream: InStream)+ BC28: Adds a file attachment to the email message.AddAttachment(AttachmentName: Text[250]; ContentType: Text[250]; InLine: Boolean; ContentId: Text[40]; AttachmentInStream: InStream)+ BC28: Adds a file attachment to the email message.AddAttachment(AttachmentName: Text[250]; ContentType: Text[250]; InLine: Boolean; ContentId: Text[40]; AttachmentInStream: InStream; MessageAlreadyRetrieved: Boolean)+ BC28: Adds a file attachment to the email message.AddAttachmentFromScenario(var EmailAttachments: Record "Email Attachments"): Adds attachments from scenario to the email message.Attachments_DeleteContent(): Boolean: Deletes the contents of the currently selected attachment.Attachments_DeleteContent(BypassSentCheck: Boolean): Boolean: Deletes the contents of the currently selected attachment.Attachments_Delete(): Boolean: Deletes the currently selected attachment.Attachments_Delete(BypassSentCheck: Boolean): Boolean: Deletes the currently selected attachment.Attachments_First(): Boolean: Finds the first attachment of the email message.Attachments_Next(): Integer: Finds the next attachment of the email message.Attachments_GetId(): BigInteger+ BC26: Gets the Id of the current attachmentAttachments_GetName(): Text[250]: Gets the name of the current attachment.Attachments_GetContent(var AttachmentInStream: InStream): Gets the content of the current attachment.Attachments_GetContentBase64(): Text: Gets the content of the current attachment in Base64 encoding.Attachments_GetContentType(): Text[250]: Gets the content type of the current attachment.Attachments_GetContentId(): Text[40]: Gets the content ID of the current attachment.Attachments_GetLength(): Integer: Gets the content length of the current attachment.Attachments_IsInline(): Boolean: Checks if the attachment is inline the message body.GetRelatedAttachments(var EmailRelatedAttachments: Record "Email Related Attachment"): Boolean: Gets the related attachments.GetNoOfModifies(): Integer(internal): Gets number of modifies on the 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 8905 “Email Message Impl.” (38 calls:
AddAttachment → AddAttachment,AddAttachmentFromScenario → AddAttachmentsFromScenario,AddHeader → AddHeader, …)
Called by
- Codeunit 4509 “Email - Outlook API Helper” (18 calls:
AddAttachmentsToMessage → AddAttachment,AddEmailAttachments → Attachments_First,AddEmailAttachments → Attachments_GetContentBase64, …) - Codeunit 4582 “SOA Retrieve Emails” (13 calls:
AddEmailAttachmentToTaskMessage → Attachments_First,AddEmailAttachmentToTaskMessage → Attachments_GetContent,AddEmailAttachmentToTaskMessage → Attachments_GetContentType, …) - Codeunit 4513 “SMTP Connector Impl.” (9 calls:
BuildSMTPMessage → Attachments_First,BuildSMTPMessage → Attachments_GetContent,BuildSMTPMessage → Attachments_GetName, …) - Codeunit 8900 “Email Impl” (9 calls:
AddRelation → GetId,BeforeReplyEmail → Get,BeforeReplyEmail → GetId, …) - Codeunit 8906 “Email Editor” (9 calls:
AddRelatedRecordsFromEmailAddress → Get,AddRelatedRecordsFromEmailAddress → GetId,BeforeOpenEmailEditor → Get, …) - Codeunit 6940 “EA Retrieve Emails” (8 calls:
AddEmailToNewAgentTask → Get,AddEmailToNewAgentTask → GetBody,AddEmailToNewAgentTask → GetSubject, …) - Codeunit 4419 “SOA Send Reply” (5 calls:
AddMessageAttachments → AddAttachment,GetMappedReplyRecipients → Get,GetMappedReplyRecipients → GetRecipients, …) - Codeunit 8361 “Financial Report Export Job” (5 calls:
CreateEmailMessage → Create,CreatePackageEmailMessage → Create,ExportExcel → AddAttachment, …) - Codeunit 9520 “Mail Management” (3 calls:
SendViaEmailModule → AddAttachment,SendViaEmailModule → Create,SendViaEmailModule → GetId) - Codeunit 1368 “Monitored Field Notification” (2 calls:
SendEmail → Create,SendEmail → GetId) - Codeunit 3307 “Payables Agent Setup” (2 calls:
TryGetSourceEmailHeader → Get,TryGetSourceEmailHeader → GetHeader) - Codeunit 3309 “PA Demo Guide” (2 calls:
SendDemoEmail → AddAttachment,SendDemoEmail → Create) - Codeunit 4398 “SOA Task Message” (2 calls:
GetMessageCcRecipients → Get,GetMessageCcRecipients → GetRecipients) - Codeunit 8890 “Send Email” (2 calls:
OnRun → Get,OnRun → GetExternalId) - Codeunit 8898 “Map Email Source” (2 calls:
InsertAttachment → AddAttachment,InsertAttachment → Get) - Codeunit 8907 “Email Viewer” (2 calls:
EditAndSend → Get,Resend → Get) - Page 3305 “PA Agent Email Task” (2 calls:
OnAfterGetCurrRecord → Get,OnAfterGetCurrRecord → GetBody) - Codeunit 6938 “EA Agent Dispatcher” (1 call:
SendEmail → Create) - Codeunit 8887 “Email Test Mail” (1 call:
OnRun → Create) - Codeunit 8901 “Email” (1 call:
HasRelations → GetId) - Codeunit 8902 “Email Scenario Attach Impl.” (1 call:
AddAttachmentToMessage → AddAttachmentFromScenario) - Codeunit 8905 “Email Message Impl.” (1 call:
Attachments_GetContent → OnGetAttachmentContent) - Page 9033 “Invite External Accountant” (1 call:
SendInvitationEmail → Create)
Recent changes
- 2026-09-21 #11612 Multiple runs of email retrieval on the same emails don’t persist again (main, BC30, fix)
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"), then bcatlas_get_procedure_body or bcatlas_get_neighbors on the returned id.