I use the provided script, “Add message(s) to DEVONthink”, to add email from my Outlook app.
Recently, Outlook has been updated with an optional “New Look” that you can switch to but toggling a button. I suspect this “New Look” is the way Outlook will be going.
When I try to add a message from this new UI, I get the error reported from Outlook “One or more messages must be selected.” But a message was selected prior to executing the script.
If I switch back to the old UI, the script works again.
I’m not sure if this is a bug with Outlook or with the script. Can someone from DT assist? Thanks!

We have no control over what Outlook reports to the script. If the new UI doesn’t report a selection, that would be an issue for Microsoft to fix.
Sure.
I guess you’re saying that it is confirmed that the UI is not reporting a selection was made? Or, is this possibly a different kind of error? If it is the former kind of error, of course this is a Microsoft problem, but I’d like to know that this is confirmed before I submit a bug report to Microsoft.
If the old UI is working and the new UI isn’t, I’d say it’s l not an issue with DEVONthink or the script.
What does this script return in the Script Editor.app in case of the new UI?
tell application "Microsoft Outlook"
set theSelection to the selected objects
return theSelection
end tell
I’m not sure I’m savvy enough to understand what you mean by “what does the script return in the Script Editor.app in case of the new UI.”
But I took a guess at what you meant and I did this:
- I copied your script into a new Script document
- I opened up Outlook using the new UI.
- Selected an message in Outlook
- Went back to the Scrip document and pressed the “Play” button.
- Result: {}
On the other hand, if I switched to the Outlook old UI and selected a message, something like this comes up:
Result: { incoming message id 333249 of application “Microsoft Outlook”}
So I suppose this means the new Outlook UI is returning null result for the command “set theSelection”. Is that what that means?
Is there another “vocabulary” (?) that new Outlook UI would use for returning the result of a selection?
Thanks!
That is correct. The new UI is returning an empty list showing the command they provided is incompatible with it at this time.
And Microsoft would have to address this issue with their AppleScript implementation.
Thanks! I’ve started a bug report with MS Outlook folks!
No problem. Let us know if you get a good word from them.
Hi,
If you use this:
set theSelection to the selection
It avoid this error…
Thanks,
BS
Can you post your suggestion within a script? Thanks.
yes, off course.
I’ve one that I’ve seen and made some changes, but it returns other error “Microsoft Outlook got an error: Can’t make missing value into type specifier.” I’m not a programmer and I’m unable to correct this.
Follows the script I’ve:
tell application "Microsoft Outlook"
try
set theSelection to the selection
if theSelection is {} then error "One or more messages must be selected."
tell application id "DNtp"
if not (exists current database) then error "No database is in use."
set theGroup to preferred import destination
end tell
repeat with theMessage in theSelection
try
set theSubject to subject of theMessage
set theSender to sender of theMessage
set theSender to (address of theSender) as string
set theSource to source of theMessage
set theDateReceived to time received of theMessage
set theDateSent to time sent of theMessage
if theSubject is equal to "" then set theSubject to pNoSubjectString
set theCategories to {}
set theList to (category of theMessage)
repeat with theCategory in theList
set theCategories to theCategories & (name of theCategory)
end repeat
set isFlagged to true
if todo flag of theMessage is (not flagged) then set isFlagged to false
set isUnread to is read of theMessage
tell application id "DNtp"
set theRecord to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string)} in theGroup
if theCategories is not {} then
set theTags to tags of theRecord
set theTags to theTags & theCategories
set tags of theRecord to theTags
end if
if isFlagged then set state of theRecord to true
if isUnread then set unread of theRecord to true
perform smart rule trigger import event record theRecord
end tell
end try
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "Outlook" message error_message as warning
end try
end tell
You’re getting the error because - as noted previously - the new interface does not report a selection. The classic interface does. This is soemthing Microsoft would have to address, not something we can fix.
yes, indeed. With the old interface it works. Thanks!!
Is there already an update on this issue? Just made the switch to the old interface to the new and the script doesn’t seem to work
What error are you seeing?
Only the old interface is scriptable but it’s still planned by Microsoft for the new interface:
https://www.microsoft.com/en-ca/microsoft-365/roadmap?filters=&searchterms=88537
But actually it was already promised for this spring and then just postponed.