# Missing Email Body Report Job

Finds filed .msg e-mails whose body is missing, lists them in an Excel report, and can repair them from a copy in a mailbox.

Configuration class: MissingEmailBodyReportJobCfg (SharepointCfg.MissingEmailBodyReportJob)

Schedule base: EveryNightScheduleCfg. The job starts at StartTime and stops at EndTime. It is off by default.

# Purpose

Some e-mails were filed without their body text: the file has a sender, recipients and attachments, but no text. Users only notice when they open the e-mail. The cause was in DMSforLegal and is fixed there; this job finds and repairs the e-mails filed before that fix.

An e-mail counts as having no body when all three body properties are missing or empty: the plain text (PR_BODY_W), the HTML (PR_HTML) and the RTF (PR_RTF_COMPRESSED). Outlook can keep the text in any one of the three, so one empty property is not enough. As Henk confirmed: "Only when all three are absent or empty is there no text content."

Only .msg files are checked. SharePoint search cannot tell whether an e-mail has a body, so the job downloads and reads every .msg file in its search.

# Configuration

# Enabled

  • Type: bool
  • Default: false
  • Description: The job does not run at all unless this is enabled.

# StartTime

  • Type: TimeSpan?
  • Default: 21:00:00
  • Description: Time of day the job starts. If the service starts inside the window (for example after a restart), the job starts right away.

# EndTime

  • Type: TimeSpan?
  • Default: 06:00:00
  • Description: Time of day the job stops, even if it is not finished. The next night it continues where it stopped.

# StartDate

  • Type: DateTime?
  • Default: 2026-01-01
  • Description: Only e-mails created on or after this date are checked. Leave empty to check e-mails of any created date.

# AdditionalSearchCriteria

  • Type: string (SharePoint search query text, KQL)
  • Default: —
  • Description: Extra search criteria, combined with AND. Example: DMSMatterCode=X to check one matter. Use StartDate to limit the date.

After changing this value, restart the scan so e-mails that were skipped before are checked:

  1. Disable the job, or wait until it is outside its window.
  2. Delete the progress file Config\MissingEmailBodyReportJobState\<configuration name>.json in the service folder, or clear Current state > Last processed created (UTC) in the configurator.
  3. Enable the job again. The next night it starts again from StartDate.

Never delete Config\MissingEmailBodyReportJob\<configuration name>\pending.jsonl: it holds report lines that are not in a report yet.

# UploadUrl

  • Type: string
  • Default: —
  • Description: Optional. When set, the Excel report is also uploaded to this library or folder, relative to SharepointUrl. The report is always saved on the server (see Report). Example: with SharepointUrl https://contoso.sharepoint.com/sites/dms, the value Shared Documents/Reports uploads to /sites/dms/Shared Documents/Reports. Start the value with / for a path from the tenant root, for example /sites/reports/Shared Documents.

# ReportIncludeFolder

  • Type: bool
  • Default: true
  • Description: Adds the folder inside the library to the report.

Sensitive information

Folder names can contain sensitive information. Turn this off when the report is shared with people who should not see them.

# ReportIncludeFileName

  • Type: bool
  • Default: false
  • Description: Adds the file name and file URL to the report.

Sensitive information

File names can contain sensitive information. Only turn this on when everyone who can read the report may see them.

# ReportIncludeSubject

  • Type: bool
  • Default: false
  • Description: Adds the e-mail subject to the report.

Sensitive information

Subjects can contain sensitive information. Only turn this on when everyone who can read the report may see them.

# RepairEnabled

  • Type: bool
  • Default: false
  • Description: Replaces each listed e-mail with the copy found in a mailbox. SharePoint Online only. Needs the Microsoft Graph application permissions Mail.Read and User.Read.All (see API Permissions).

When RepairEnabled is on, the job checks at start that it is connected to SharePoint Online, that the app registration (SharepointClientID) is set, and that both Graph permissions are granted. If one of these is missing, the job does not run that night and logs one error that names what is missing. Nothing is checked or skipped, so the next run continues from the same point once the problem is fixed.

The check reads the permissions granted in Entra ID. A tenant that grants Mail.Read only through Exchange RBAC for Applications (without the Entra ID permission) fails this check. Grant the Entra ID permission instead; it can be limited to some mailboxes with an Exchange Application Access Policy.

# Report

One Excel file is made per run that lists at least one e-mail. It is always saved in the service folder as Reports\MissingEmailBodyReport\<configuration>\MissingEmailBodyReport_<configuration>_<yyyyMMdd_HHmm>.xlsx, and is also uploaded when UploadUrl is set. A run that finds nothing makes no file.

The saved files are not cleaned up. They hold client and matter names (and folder names, file names and subjects when switched on), so only people who may see this information should have access to the service folder.

Column Content
Status See Statuses.
FixedFrom The mailbox the e-mail was repaired from.
DocumentLink A link that opens (downloads) the file.
SiteUrl The site, server-relative from the root, for example /sites/clients.
Library The document library, server-relative from the root, for example /sites/clients/C001-M001.
Folder The folder inside the library, for example Correspondence/2026. Empty for the library root. Only with ReportIncludeFolder (on by default).
ListItemId The list item ID in the library.
FileUniqueId The unique ID of the file.
Created, CreatedBy When and by whom the e-mail was filed.
ClientCode, ClientName, MatterCode, MatterName The client and matter.
FileName, FileUrl Only with ReportIncludeFileName.
Subject Only with ReportIncludeSubject.
Remark More detail; several remarks are separated by ;.

To find a file from the report, search SharePoint for UniqueId:<FileUniqueId>, or filter the library view on ID equal to ListItemId.

# Statuses

Status Meaning
Report only The e-mail has no body and was not changed: repair is off, or the e-mail is rights-protected (Remark rights-protected).
Fixed The e-mail was repaired. FixedFrom shows the mailbox.
Not found No usable copy was found. The Remark says No internal mailbox found (only external addresses), Not found in <n> mailbox(es) (followed by the mailboxes that refused access, and for a damaged file the copies not used, if any), or mailbox copy has no body.
No message id The e-mail has no internet message id, so it cannot be looked up.
Could not be read The file could not be downloaded, is not a valid e-mail file, or its library could not be loaded. It was not repaired. With repair on, the Remark of a damaged file says why: No internet message id, or the same reasons as Not found. Otherwise the Remark gives the cause, for example not a valid e-mail file.
Error The repair failed; the Remark has the reason. The file is unchanged, except that a check-out undone before the write stays undone (the Remark then names the user). When the job had checked the file out itself, it undoes that check-out, so the file is not left checked out to the service; if that fails too, the Remark says left checked out to the service; undo the check-out by hand. When the new body was saved but publishing or approving failed, the Remark says e-mail body restored, but not published or approved; do that by hand. interrupted during repair; check the file means the service stopped while it replaced the file.

# How repair works

For each e-mail without a body, the job looks up its internet message id in these mailboxes, in this order, and stops at the first copy it finds. The id is taken from the filed e-mail itself; the Internet message id column is only used when the file is damaged.

  1. the person who filed it;
  2. the sender;
  3. the To and Cc recipients.

Addresses on the same domain as the person who filed it are tried first. External addresses and guest users (no mailbox in the tenant) are skipped and do not count. At most 10 internal mailboxes are searched.

A filed e-mail that can be read keeps everything that was filed: sender, recipients, dates, headers and attachments. It only gets its body back from the mailbox copy. If the body shows an inline image that the file does not have, the image is added too (Remark inline image(s) added: n). Existing attachments are never changed. When the mailbox copy has no text either (for example a scan), the file is not changed: the row shows Not found with mailbox copy has no body.

A filed file that is damaged (not a valid e-mail file) is rebuilt from the mailbox copy, the way Epona365 Office files e-mails. The Remark says original was not a valid e-mail file. Because the message id and addresses of a damaged file come from columns that users can edit, a copy is only used when it is in the mailbox of the person who filed it, or when that person sent or received it. Other copies are skipped, and the Remark names them: copy not used, the filer is not on it: <mailboxes>. Some attachments cannot be rebuilt, because Microsoft Graph does not return them as the original Outlook item. These are left out and named in the Remark; the e-mail is still repaired:

In the mailbox copy In the rebuilt e-mail
Files and inline images Kept
Attached e-mails Kept, with their own attachments, up to 30 levels deep
Files inside an attached e-mail that Graph returns without content Left out: attached file not included
OneDrive or SharePoint links Kept as a link (.url file)
Calendar items Left out: calendar item not included
Contacts, tasks and other items Left out, for example contact not included
Attached items Graph cannot read Left out: attached item not included

A rights-protected e-mail is never repaired. A rights-protected mailbox copy is never used either, also when only an attached e-mail inside it is rights-protected: the row shows Error with mailbox copy is rights-protected.

The repaired e-mail is saved as a new version of the same file, in .msg format. Its columns, Created and Created By stay the same; Modified and Modified By show the repair. The empty version stays in the version history.

A rebuilt e-mail also gets its e-mail columns (sender, recipients, dates, subject and so on) and the e-mail content type filled from the rebuilt file, the same way as the Update Email Metadata job. This adds no extra version. If that fails, the e-mail is still repaired and the Remark says e-mail columns not updated; see the service log.

  • Checked-out file: the check-out is undone and the file is repaired. Changes the user had not checked in are lost. The Remark names the user, also when the write fails afterwards (row Error).
  • Library without versioning: the file is overwritten and the Remark says versioning is off; original overwritten.
  • Library with minor versions, content approval or required check-out: the repaired e-mail gets the same visibility as the empty one had. A published e-mail is published again (Remark published); a draft stays a draft (Remark saved as draft, as the filed e-mail). With content approval, the repair is approved only when the empty e-mail was approved (Remark published and approved); otherwise it waits for approval as usual. With required check-out, the job checks the file out, writes it and checks it in.
  • Record-locked file or access denied: the file is not changed and the row shows Error.

# Logging

The report is the log for each e-mail. The service log only shows:

  • one line per run with the duration, the counts and where the report was saved and uploaded (also when the scan, the save or the upload stops);
  • one error when the repair cannot start (missing permission, no app registration, not SharePoint Online);
  • one warning when every mailbox search was denied;
  • errors that stop the run. When Microsoft Graph keeps refusing or cannot be reached (lost permission, expired secret, throttling that lasts, no connection), the run stops at that e-mail and the next night continues from there, so no e-mail is skipped.

# Operations

  • Long runs and restarts: progress is saved every 25 e-mails or 5 minutes, and report lines are written to disk as soon as they are found. After a restart the job continues where it stopped; nothing is lost from the report.
  • Large backlog: the job continues each night until it has checked everything since StartDate. After that it checks only new e-mails.
  • Recent e-mails wait 12 hours: a run only checks e-mails created at least 12 hours before it starts. SharePoint search can take minutes to hours to index a new e-mail, and the job must not move past one that is not indexed yet. With the default window starting at 21:00, a run checks what was filed before 09:00 that day; e-mails filed later are checked the next night.
  • Upload failures: the report stays saved on the server and is not made again. The service log names the file; upload it by hand.
  • Save failures: when the report cannot be saved on the server, its lines are kept and go into the report of the next run.
  • Configurator: saving the configuration while the job runs can set the progress back. E-mails are then checked again and may appear in a second report. Save the configuration outside the job window.
  • Damaged progress file: if the progress file cannot be read, the job fails at start. Delete the progress file to start again from StartDate.
  • Security: with repair on, the app reads e-mail in the mailboxes it searches. Limit the mailboxes with an Exchange Application Access Policy when needed; denied mailboxes are shown in the report.
Last Updated: 11/23/2026, 12:39:01 PM