Sometimes headers from Outlook missing

A user of my application Mail Archiver X wants to archive emails from Outlook. However, only a small number of emails are being archived. The app can log all AppleScripts and the result. When getting the headers some of the emails don’t have one - at all.

I have AppleScripts to get the mailboxes and for each mailbox the number of emails in the mailbox.

AppleScript:

property Mailbox0 : "mailbox1"
property Mailbox1 : "mailbox2"
property Mailbox2 : "mailbox3"
property Mailbox3 : "account1"
property currentMessageStr : "40"
with timeout of 10000 seconds
set currentMessage to currentMessageStr as integer
tell application "/Applications/Microsoft Outlook.app"
set theFolder to mail folder Mailbox0 of mail folder Mailbox1 of mail folder Mailbox2 of exchange account Mailbox3
return headers of message currentMessage of theFolder
end tell
end timeout

I made the guy a direct AppleScript but the user is a lawyer and security conscious. He didn’t want to run the AppleScript.

Any ideas what could cause the missing headers?

macOS 14.1