---
id: object/codeunit/4582
type: object
title: Codeunit 4582 "SOA Retrieve Emails"
summary: Codeunit 4582 "SOA Retrieve Emails" in SalesOrderAgent (Microsoft.Agent.SalesOrderAgent). 4 public procedures, 2 events, 3 event subscribers. Introduced in BC29, still in BC30.
tier: official
language: en
tags:
  - codeunit
  - salesorderagent
versions:
  introduced: "29"
  last_changed: null
  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: 146824f86e43ac0f8d3d75499ab356f984ee2e6ac686fac107209a9afb56d510
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/SalesOrderAgent/app/src/Integration/SOARetrieveEmails.Codeunit.al
    title: src/Apps/W1/SalesOrderAgent/app/src/Integration/SOARetrieveEmails.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/11063
    - change/bcapps/10567
object_type: codeunit
object_id: 4582
name: SOA Retrieve Emails
namespace: Microsoft.Agent.SalesOrderAgent
app: SalesOrderAgent
extends: null
first_version: "29"
last_version: "30"
present_in:
  - "29"
  - "30"
changed_in: []
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 14
  events: 2
  subscribers: 3
relations:
  out: 1
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 2
  calls: 10
  called_by: 2
  implements: 0
---

# Codeunit 4582 "SOA Retrieve Emails"

> Codeunit 4582 "SOA Retrieve Emails" in SalesOrderAgent (Microsoft.Agent.SalesOrderAgent). 4 public procedures, 2 events, 3 event subscribers. Introduced in BC29, still in BC30.

SalesOrderAgent · Microsoft.Agent.SalesOrderAgent · BC29-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/SalesOrderAgent/app/src/Integration/SOARetrieveEmails.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Internal |
| TableNo | SOA Setup |
| Permissions | tabledata "Email Inbox" = rd |

## Events published

- `OnAddEmailToAgentTask(SOASetup: Record "SOA Setup"; var SOAEmail: Record "SOA Email")` (internal)
  - subscribers: [Codeunit 4582 "SOA Retrieve Emails"](../codeunit/4582.md) OnAddEmailToAgentTaskSubscriber
- `OnAfterProcessEmail(EmailInboxId: BigInteger)` (internal)
  - subscribers: [Codeunit 4582 "SOA Retrieve Emails"](../codeunit/4582.md) OnAfterEmailProcessed

## Event subscriptions

- OnAddEmailToAgentTaskSubscriber subscribes to Codeunit "SOA Retrieve Emails" OnAddEmailToAgentTask
- OnAfterEmailProcessed subscribes to Codeunit "SOA Retrieve Emails" OnAfterProcessEmail
- OnBeforeDeleteSOAEmailEvent subscribes to Table "SOA Email" OnBeforeDeleteEvent

## Procedures

- `AddEmailInboxToSOAEmails(SOASetup: Record "SOA Setup"; var EmailInbox: Record "Email Inbox")`
- `AddEmailToNewAgentTask(var SOASetup: Record "SOA Setup"; var EmailInbox: Record "Email Inbox"; var SOAEmail: Record "SOA Email")`
- `AddEmailToExistingAgentTask(SOASetup: Record "SOA Setup"; EmailInbox: Record "Email Inbox"; var SOAEmail: Record "SOA Email")`
- `GetAgentTaskTitle(SenderName: Text[250]): Text[150]` (internal)

Plus 5 local procedures.

## Triggers

OnRun

## Relations

- runs on [Table 4325 "SOA Setup"](../table/4325.md)

## 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 4400 "SOA Setup"](../codeunit/4400.md) (16 calls: `AddEmailAttachmentToTaskMessage → DocumentExceedsPageCountThreshold`, `AddEmailAttachmentToTaskMessage → GetFeatureName`, `AddEmailAttachmentToTaskMessage → GetMaxNoOfAttachmentsPerEmail`, …)
- [Codeunit 8904 "Email Message"](../codeunit/8904.md) (13 calls: `AddEmailAttachmentToTaskMessage → Attachments_First`, `AddEmailAttachmentToTaskMessage → Attachments_GetContent`, `AddEmailAttachmentToTaskMessage → Attachments_GetContentType`, …)
- [Codeunit 8703 "Feature Telemetry"](../codeunit/8703.md) (8 calls: `AddEmailAttachmentToTaskMessage → LogError`, `AddEmailAttachmentToTaskMessage → LogUsage`, `AddEmailToAgentTask → LogUsage`, …)
- [Codeunit 4315 "Agent Task Builder"](../codeunit/4315.md) (4 calls: `AddEmailToAgentTask → TaskExists`, `AddEmailToNewAgentTask → Create`, `AddEmailToNewAgentTask → GetAgentTaskMessageCreated`, …)
- [Codeunit 4316 "Agent Task Message Builder"](../codeunit/4316.md) (4 calls: `AddEmailAttachmentToTaskMessage → AddAttachment`, `AddEmailToExistingAgentTask → Create`, `AddEmailToExistingAgentTask → Initialize`, …)
- [Codeunit 8901 "Email"](../codeunit/8901.md) (3 calls: `AddEmailInboxToSOAEmails → ApplyEmailCategory`, `AddEmailInboxToSOAEmails → MarkAsRead`, `RetrieveEmails → RetrieveEmails`)
- [Codeunit 4396 "SOA Email Setup"](../codeunit/4396.md) (2 calls: `RetrieveEmails → GetEmailCountProcessedWithin24hrs`, `RetrieveEmails → GetMaxNoOfEmails`)
- [Codeunit 4398 "SOA Task Message"](../codeunit/4398.md) (2 calls: `AddEmailToExistingAgentTask → MessageRequiresReview`, `AddEmailToNewAgentTask → MessageRequiresReview`)
- [Codeunit 4590 "SOA Billing"](../codeunit/4590.md) (2 calls: `AddEmailToExistingAgentTask → LogEmailRead`, `AddEmailToNewAgentTask → LogEmailRead`)
- [Codeunit 4587 "SOA Impl"](../codeunit/4587.md) (1 call: `RetrieveEmails → GetProcessLimitPerDay`)

## Called by

- [Codeunit 4415 "SOA Create Task Impl"](../codeunit/4415.md) (1 call: `CreateTask → GetAgentTaskTitle`)
- [Codeunit 4586 "SOA Dispatcher"](../codeunit/4586.md) (1 call: `RunSOAgent → (object)`)

## Recent changes

- 2026-09-06 [#11063 Prevent Sales Order Agent from skipping emails moved into monitored folders](../../changes/bcapps/11063.md) (main, BC30, fix)
- 2026-08-30 [#10567 SOA : Create Task from TaskPane respects review configuration for known senders](../../changes/bcapps/10567.md) (main, BC30, fix)

## Across versions

- Present in: BC29-30
- Changed (declaration) in: none

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