Deduplicate PDF email attachments without losing their case

9 August 2026

An overhead view of a person typing on a laptop.
Illustrative photograph. Cropped and resized. Photo: “Woman Working Business” — Kristin Hardwick / NegativeSpace. · CC0 1.0

The same attachment can arrive twice for one case and once for another. In the supplied simulation, five deliveries produce different outcomes for repeats, new case contexts and a malformed PDF. Follow the attachment manifest to see when processing can be reused and when the new submission still needs its own record.

Related articles

Which receipt, attachment and case are you tracking?

Imagine a shared mailbox receiving documents for several customer cases. The same PDF may arrive twice because a notification is repeated, because somebody forwards a thread, or because two separate cases use the same form. Those situations need different treatment. Transport duplication should not create extra work; a new submission should retain its own context even when processing can reuse an existing result.

Define the mailbox, permitted business purpose and point of acceptance. For example, a proposed intake service might acknowledge internally only after it has durably recorded the attachment and its source context. Moving a message into a folder would then be an organisational action, not the sole evidence that processing completed.

Where this guidance stops

Microsoft Graph provides the bounded mail-platform example below. Its identifiers and permissions should not be assumed to apply to every mail service. This article establishes a proposed intake design and a local synthetic test; it does not demonstrate an ArkePDF mail connector, send emails or access a real mailbox.

Set access and attachment rules

Mail API permissions and file handling

Select the runtime identity and document its permitted mailbox boundary. Graph's attachment retrieval documentation lists Mail.Read for message attachments and distinguishes file, item and reference attachments. A reference attachment is a link, not automatically downloadable file content through the same raw-content route. Check the attachment API contract before writing a single generic download handler.

Decide which attachment types and formats the business accepts. A nested email, a cloud link and an attached PDF need different handling. Preserve the original filename as metadata, but use a generated storage identifier. The name should not control a filesystem path or decide which customer receives the document.

Intake fieldWhy it belongs in the manifest
Mailbox and message identifierIdentifies the source context
Attachment identifier and typeDistinguishes parts of one message
Sender and receipt timeSupports investigation and routing review
Business purpose or case referenceDetermines the permitted processing context
Content checksum and sizeRecords the acquired bytes
Validation and processing stateExplains acceptance, rejection or delay

Treat incoming content as untrusted. OWASP recommends layered file validation, size limits and controlled storage; an asserted MIME type can be spoofed, and a file signature alone is insufficient. Its upload guidance supports these controls. A PDF parser accepting a file does not provide malware clearance, authorisation or proof that its business content is correct.

Five local deliveries, including a damaged PDF

Inputs, assumptions and the expected result

The original synthetic manifest contains five delivery events. Valid attachments use the programme's labelled, three-page synthetic table PDF. A separate fixture contains plain text named malformed.pdf. There is no customer information or actual email message.

The proposed flow is:

FromConditionNext step
Delivery and source contextAlwaysContext already recorded?
Context already recorded?YesRecord duplicate delivery
Context already recorded?NoAttachment passes intake checks?
Attachment passes intake checks?NoOwned exception queue
Attachment passes intake checks?YesSame approved reuse key?
Same approved reuse key?YesReuse job; add source context
Same approved reuse key?NoCreate job; retain source context

The proposed rule first identifies a submission by mailbox, message and attachment. It then decides whether processing can be reused using the mailbox, business purpose, content checksum and operation version. A different purpose creates separate work even if the bytes match. This is an explicit business rule for the example, not a universal deduplication policy.

DeliveryMeaningExpected treatment
D01First attachment for case ACreate a job
D02Repeated delivery of D01Record transport duplication
D03New message, same bytes and case AReuse job; retain new source context
D04Same bytes for case BCreate a separate job
D05Plain text presented as a PDFQuarantine after parse failure

The local intake script ran with Python 3.12.14 and pypdf 6.10.0. It produced two processing-job records, retained four unique source contexts and identified one duplicate delivery. D03 was attached to the existing case-A job. D05 raised a PDF parsing error and entered the quarantine state. The valid fixture was parsed as three pages. The saved results include the exact checksums and decisions.

What the results establish

The observed results demonstrate local manifest handling, the stated reuse rule and a deliberately simple malformed-file check. They do not demonstrate OCR, document transformation, security scanning, mail subscriptions or mailbox permissions. A production workflow also needs durable storage, concurrency control and recovery across process restarts; the in-memory example does not prove those properties.

Handle duplicate and failed intake

Thread duplicates, retries and malformed attachments

Choose identifiers with the platform's actual behaviour in mind. Microsoft documents that default Outlook item IDs can change when items move; requesting immutable IDs preserves identity within the same mailbox, with stated exceptions such as movement to an archive mailbox. The request header must be applied where required. Read the immutable-ID guidance. Record the chosen identity scheme so later operators can interpret stored references.

Keep source-context deduplication separate from content reuse. A repeated event for one attachment should recover the same intake record. A forwarded attachment may add a new sender and receipt time to an existing processing job. A revised attachment should receive a new checksum and a decision about whether it supersedes an earlier submission. Neither a common subject line nor a shared filename answers those questions reliably.

For transient download failures, retain an attempt record and use bounded retries. For a malformed, encrypted or unsupported file, expose the reason to an authorised reviewer. Do not repeatedly send the same unreadable bytes through processing and count each retry as a new document.

An uncertain outcome requires reconciliation. If attachment storage succeeded but the worker acknowledgement was lost, locate the stored intake record before fetching and scheduling again. If processing finished but its result was not linked back, repair that relationship rather than silently creating another job. Track the oldest unresolved submission as well as totals.

Acceptance checklist for an email attachment PDF processing workflow

Safe uploads, alerts and reconciliation

Use synthetic messages in an approved mailbox to exercise the complete flow before admitting business documents. Include multiple PDFs in one email, a repeated event, a forwarded attachment, a changed document with the same filename, an unsupported attachment type and a parse failure. Include an access-revocation case and a worker interruption after durable acceptance.

For each submission, verify:

  • The stored bytes match the acquired attachment checksum.
  • Its mailbox, message, attachment and business-purpose references remain available.
  • Deduplication preserves distinct submissions and follows the approved reuse rule.
  • Quarantined files are inaccessible through ordinary result links.
  • A failure has a named owner and an actionable state, not an unexplained disappearance.
  • The final result or exception can be traced back without relying on a subject-line search.

Reconcile unique submissions, not just deliveries. In the local example, five deliveries become four source contexts: three valid contexts link to two jobs and one context is quarantined. That accounting makes the duplicate and reused work visible. In a real system, add records for partial downloads, rejected types and pending work so the totals still explain every accepted event.

Deploy with a review queue

Exception ownership and retention policy

Give the mailbox owner responsibility for business routing, the integration owner responsibility for delivery and retries, and the document reviewer responsibility for content exceptions. Assign deadlines by business need. An inbox that receives documents overnight still needs an agreed response when the first morning deadline is approaching.

Set retention separately for source messages, acquired attachments, processing copies, results and diagnostic records. A mail-folder cleanup should not accidentally remove the only provenance record. Conversely, retaining a checksum does not mean the full attachment must remain available indefinitely. Follow the organisation's approved schedule and any applicable preservation requirements.

Begin with one mailbox and a bounded purpose. Compare the intake ledger with an independently inspected set of synthetic submissions, then rehearse stopping new intake and recovering outstanding work. Expand only after the service can explain both successful documents and exceptions without depending on an operator's memory.

Identify email attachments with stable processing keys

Distinguish two same-named attachments in one message with an identifier for each attachment as well as the email itself.

Read “Identify email attachments with stable processing keys”.

Route encrypted email attachments for authorised review

Record receipt of the encrypted attachment and route it to an authorised reviewer while its contents remain unread.

Read “Route encrypted email attachments for authorised review”.

Handle an email without the expected attachment

Record the missing attachment against the incoming message and link the eventual file to that open request.

Read “Handle an email without the expected attachment”.

Track attachment versions across email replies

Trace attachments across replies and inspect a replacement’s contents before deciding whether a familiar filename represents a revision or a repeat.

Read “Track attachment versions across email replies”.

Design a manual review queue for PDF email intake

This section answers a narrower question than the rest of this page, and it does not mint a new URL. The original contribution preserved here is a synthetic message/attachment manifest and idempotent processing test.

A person should see a message that the workflow could not finish safely. The queue is that place, and a repeated delivery must not create a second job.

DeliveryMessage idAttachment idJobs created
FirstYour idYour idExpect one, or one review item
The same message againThe sameThe sameExpect no second job

Labelled synthetic case. Deliver one harmless message twice. Count jobs. A message you cannot match to a case goes to review with the reason written on it, not into a guessed case.

The rest of this page remains the parent decision. Use the table for the question in the heading, and leave a cell blank rather than filling it from memory.

Sources

Published by Arke Technologies (Pty) Ltd, Johannesburg. Drafted with ChatGPT. Editorial and technical checks by Kairos (Codex). The linked articles were drafted with NotebookLM and independently checked and edited by Kairos (Codex).