I just upgraded to 365 from 2011. The script below worked fine in 2011 for permanently deleting messages from Outlook. It stopped under 365. I tinkered with it but cannot get it to work under 365. Does anybody see what it could be?
tell application "Microsoft Outlook"
set theMsgs to the current messages -- selected messages
try
repeat with theMsg in theMsgs
permanently delete theMsg
end repeat
on error errMsg number errNum
set theSubject to subject of theMsg
set theFolder to name of «class stor» of theMsg
beep
display dialog errMsg & return & return & errNum & return & return & "(Erroring on message: " & theSubject & " in " & theFolder & ")" with icon 2
end try
end tell
First thing to do, from the Script Editor, look at the dictionary of the application.
The instruction below is supposed to trigger a function whose “old name” is no longer recognized.
set theFolder to name of «class stor» of theMsg
It’s the only useful info given in your message.
Would help to give us more by running this edited version
tell application "Microsoft Outlook"
set theMsgs to the current messages -- selected messages
log result
try
repeat with theMsg in theMsgs
log theMsg
permanently delete theMsg
log "Point 05"
end repeat
on error errMsg number errNum
log errMsg &", number: "&errNum -- was a typo here
set theSubject to subject of theMsg
log "Point 06"
log theSubject
set theFolder to name of «class stor» of theMsg
log "Point 07"
beep
display dialog errMsg & return & return & errNum & return & return & "(Erroring on message: " & theSubject & " in " & theFolder & ")" with icon 2
end try
end tell
and return here the complete log history returned by the Script Editor
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 25 juin 2020 15:57:56
I don’t know Outlook.
What is really selected, an opened message or a row describing a message in a viewer.
One more time you ask about a problem striking on your machine but not of an other one.
I may be wrong but my first idea is that you aren’t putting the app in the correct setting required to get the script working.
It may also due to a script wrongly saved as it was in a long thread some times ago.
Given what I see here and there on the web
the selection
and
current messages
aren’t containing the same objects.
It would help to send to my mailbox:
(1) a screenshot displaying what is selected when you execute the script
(2) the exact script which you used so that I may check that it’s a clean one.
You may also look at the prefpane dedicated to Privacy.
In mine, Mail is listed among the apps allowed to control the computer.
Is Merdosoft Outlook listed on your’s ?
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 27 juin 2020 18:24:19
Morning, I was testing today and indeed the old/original script worked for me two or three times and stopped working. Did you test more than once? Would you mind testing again?
this is the result I get when running it if it does not work.
tell application "Microsoft Outlook"
get current messages
--> {}
end tell
Hi. Still works. When no msg is selected, you will get the empty brackets result. If one or more messages are selected, you will get a list of their references (eg,
{incoming message id 58443 of application "Microsoft Outlook", incoming message id 58409 of application "Microsoft Outlook"}
when two msgs are selected.
Since you’re running a repeat loop that deletes msgs, it is expected that when all msgs have been deleted, the last repeat will produce an empty list.
You could add some code to test for how many msgs remain (whether the remaining count is 1 or greater), and if none remain, then exit the repeat.
Kerflooey thanks for testing, reporting and good morning.
It is indeed a strange phenomenon.
First of I am running the script Yvan send me in a private mail.
tell application "Microsoft Outlook"
set theMsgs to the selection -- selected messages
log result
try
repeat with theMsg in theMsgs
log theMsg
permanently delete theMsg
log "Point 05"
end repeat
on error errMsg number errNum
log errMsg & ", number: " & errNum
set theSubject to subject of theMsg
log "Point 06"
log theSubject
set theFolder to name of «class stor» of theMsg
log "Point 07"
beep
display dialog errMsg & return & return & errNum & return & return & "(Erroring on message: " & theSubject & " in " & theFolder & ")" with icon 2
end try
end tell
First I always only try to delete one message at the time. And, as I am not a master scripter, I would not know how to do this.
There is another interesting phenomenon, like this AM I wanted to make a QuickTime movie to post how it does not work. As this might help us solve it. As soon as I start QT the script starts working.
Anyway we plough on as somewhere and somehow it must work as intended.
PS here the error message I get in the log
tell application "Microsoft Outlook"
get selection
--> outgoing message id 7104
(*outgoing message id 7104*)
count outgoing message id 7104
--> 1
(*item 1 of outgoing message id 7104*)
permanently delete item 1 of outgoing message id 7104
(*Point 05*)
end tell
I simplified the script to bare bones and it still gives me the same error.
tell application "Microsoft Outlook"
set theMessages to the selection
repeat with theItem in theMessages
permanently delete theItem
end repeat
end tell
I get:
error "Microsoft Outlook got an error: item 1 of calendar event id 1198 doesn’t understand the “permanently delete” message." number -1708 from item 1 of calendar event id 1198
and yes no calendar event is selected, I select a mail message!
getting desperate i wonder if there is anybody who has an idea as to why this happens? how to fix? etc.
What you report is not an error message, it’s the log history returned by a script which behaved flawlessly.
If an error stroke you would have seen its message, its number, {Point 06), the subject of the message, (Point 07)
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 7 juillet 2020 11:43:22
I’m desperate. How may you imagine that Outlook report a selected calendar event if you don’t select such item ?
I hate Merdosoft but their products do more or less what they are designed for without any form of fantasy or imagination.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 7 juillet 2020 11:50:54
You are the only one supposed to be able to know what you did on these different machines and which are the settings of the application and the system on these machines.
Don’t worry but, from my point of view, as I already wrote, the explanation of the selection of calendar event is somewhere between a chair and a keyboard, not in the code of the used application.
Alas it’s clear that if you don’t know what you did I doubt that somebody here will be able to guess that.
You may ask Uncle Donald T, maybe he is aware of a chinese gremlin able to corrupt your machine.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 7 juillet 2020 19:55:14