[Bug]: Inline-only email attachments are skipped because `hasAttachments` is used as a fetch gate
Nobody has claimed this yet.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
Description
Describe the issue
The Outlook/Graph email integration uses the message's hasAttachments property to decide whether to fetch attachments at all. However, hasAttachments only reflects regular attachments — it excludes inline attachments (e.g. images pasted into the email body). As a result, messages containing only inline attachments report hasAttachments: false, causing the attachment-fetch step to be skipped even though the attachments are genuinely present and retrievable via $expand=attachments. This means inline-only attachments are silently lost.
Expected behavior
Attachments should be retrieved for any message that actually has them, regardless of whether they're inline or regular. Specifically, I expected the attachment-fetch step to run unconditionally (not gated on hasAttachments), so that a message containing only an inline image would still have that attachment fetched via $expand=attachments — with any distinction between inline and regular attachments handled afterward, per-attachment, using isInline and contentId/cid: correlation, rather than being used upfront to decide whether to fetch at all.
Steps to reproduce
- In Business Central, using a feature that processes inbound email via the Outlook/Graph integration (e.g. an AI agent such as the Sales Order Agent or Payables Agent), have an external sender send an email where the only attachment is an inline image — for example, a screenshot pasted directly into the body of the email, with no separate file attached.
- Let Business Central pick up and process the incoming email through the normal inbound flow.
- Observe that the email is processed as if it has no attachments — the inline image is not retrieved, stored, or surfaced anywhere in BC.
- Enable diagnostic/trace logging (or debug) around the attachment-fetching logic in the Outlook API helper codeunit, and confirm that the
hasAttachmentsvalue returned for this message isfalse, causing the codeunit to skip the attachment-fetch call. - As a control, send a second test email to the same BC inbound flow, this time with a regular (non-inline) file attachment alongside or instead of the inline image. Confirm that in this case
hasAttachmentsistrueand the attachment is fetched and processed correctly. - Comparing steps 3–5 confirms the defect is specific to messages containing only inline attachments: the codeunit's reliance on
hasAttachmentsas a pre-fetch gate causes those attachments to be silently dropped, even though they are present and retrievable.
Additional context
No response
I will provide a fix for a bug
- I will provide a fix for a bug
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Outlook API helper codeunit and trace the attachment-fetch step that is gated by the message's hasAttachments value. Reproduce with an inline-only image and diagnostic logging, then verify that inline attachments are fetched and processed while regular attachments continue to work.
Written by the indexing model from the issue text.
Assessment
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100