Thursday, July 9, 2020

#1 2020-06-25 07:24:18 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Outlook in Office 365 Applescript to delete message no longer working.

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?

Applescript:

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

Thanks

Offline

 

#2 2020-06-25 07:59:01 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4544

Re: Outlook in Office 365 Applescript to delete message no longer working.

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.

Applescript:

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

Applescript:

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

Last edited by Yvan Koenig (2020-06-29 07:17:19 am)

Offline

 

#3 2020-06-25 02:06:47 pm

kerflooey
Member
Registered: 2011-07-07
Posts: 186

Re: Outlook in Office 365 Applescript to delete message no longer working.

Hi ChangeAgent: This script works for me on Mojave 10.14.6 and the current 365 with an Exchange account.


Filed under: delete, Outlook

Offline

 

#4 2020-06-27 04:18:40 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

Yvan Koenig wrote:

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.

Applescript:

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

Applescript:

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: "&errNbr
       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



Morning Yvan sorry for the delay, but here all hell is loose.

here is the result of your script.

Applescript:

tell application "Microsoft Outlook"
   get current messages
       --> {}
   (**)
end tell

Offline

 

#5 2020-06-27 04:22:36 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

kerflooey wrote:

Hi ChangeAgent: This script works for me on Mojave 10.14.6 and the current 365 with an Exchange account.



strange, as it refuses to do anything here.

Offline

 

#6 2020-06-27 08:50:20 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4544

Re: Outlook in Office 365 Applescript to delete message no longer working.

ChangeAgent wrote:
Yvan Koenig wrote:

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.

Applescript:

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

Applescript:

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: "&errNbr
       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



Morning Yvan sorry for the delay, but here all hell is loose.

here is the result of your script.

Applescript:

tell application "Microsoft Outlook"
   get current messages
       --> {}
   (**)
end tell



I'm not sure of what mean "current message" in Outlook idiom.
Is it an open message or is it, as you commented a message justv selected in a viewer ?

Had you really open (or select) at least one message before running the script ?
If you didn't, such result is normal.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 27 juin 2020 16:46:28

Offline

 

#7 2020-06-27 09:25:47 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

I'm not sure of what mean "current message" in Outlook idiom.
Is it an open message or is it, as you commented a message justv selected in a viewer ?



Outlook open, select a message, run script, no result.

Had you really open (or select) at least one message before running the script ?
If you didn't, such result is normal.



yes I did, that is how the script worked in the past.  select message, run script, messages nuked.

Offline

 

#8 2020-06-27 10:24:26 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4544

Re: Outlook in Office 365 Applescript to delete message no longer working.

ChangeAgent wrote:

I'm not sure of what mean "current message" in Outlook idiom.
Is it an open message or is it, as you commented a message just selected in a viewer ?



Outlook open, select a message, run script, no result.

Had you really open (or select) at least one message before running the script ?
If you didn't, such result is normal.



yes I did, that is how the script worked in the past.  select message, run script, messages nuked.



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

Offline

 

#9 2020-06-28 03:48:47 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

I send you the stuff Yvan.

Last edited by ChangeAgent (2020-06-28 03:55:17 am)

Offline

 

#10 2020-06-28 03:54:56 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

Yvan, greetings

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 ?



Merdosoft is allowed indeed. 

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.



Not sure what you mean there?

Offline

 

#11 2020-06-29 03:14:29 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

kerflooey wrote:

Hi ChangeAgent: This script works for me on Mojave 10.14.6 and the current 365 with an Exchange account.



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.

Applescript:

tell application "Microsoft Outlook"
   get current messages
       --> {}
end tell

Last edited by ChangeAgent (2020-06-29 03:16:31 am)

Offline

 

#12 2020-06-29 01:55:25 pm

kerflooey
Member
Registered: 2011-07-07
Posts: 186

Re: Outlook in Office 365 Applescript to delete message no longer working.

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,

Applescript:

{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.

Browser: Safari 605.1.15
Operating System: macOS 10.14


Filed under: Outlook

Offline

 

#13 2020-06-30 12:01:33 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

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.

Applescript:

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

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.



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

Applescript:

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

Last edited by ChangeAgent (2020-06-30 12:04:49 am)

Offline

 

#14 Yesterday 03:34:57 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

I am still struggling with this one. 

I simplified the script to bare bones and it still gives me the same error.

Applescript:


tell application "Microsoft Outlook"
   set theMessages to the selection
   repeat with theItem in theMessages
       permanently delete theItem
   end repeat
end tell

I get:

Applescript:

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.

Offline

 

#15 Yesterday 03:43:30 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4544

Re: Outlook in Office 365 Applescript to delete message no longer working.

ChangeAgent wrote:

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.

Applescript:

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

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.



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

Applescript:

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



What a mess.

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

Offline

 

#16 Yesterday 03:50:59 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4544

Re: Outlook in Office 365 Applescript to delete message no longer working.

ChangeAgent wrote:

I am still struggling with this one. 

I simplified the script to bare bones and it still gives me the same error.

Applescript:


tell application "Microsoft Outlook"
   set theMessages to the selection
   repeat with theItem in theMessages
       permanently delete theItem
   end repeat
end tell

I get:

Applescript:

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.




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

Offline

 

#17 Yesterday 06:00:42 am

ChangeAgent
Member
From:: Scotland
Registered: 2008-03-07
Posts: 336

Re: Outlook in Office 365 Applescript to delete message no longer working.

well I am not the biggest MS fan either.  but I am stuck with it for compatibility reasons. 

could it be the mac somewhere?  see I am not always able to recreate the problem and get sometimes different results on different machines.

see now on one machine when I run the script it opens the message.

Last edited by ChangeAgent (Yesterday 06:02:53 am)

Offline

 

#18 Yesterday 11:55:20 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4544

Re: Outlook in Office 365 Applescript to delete message no longer working.

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

Last edited by Yvan Koenig (Yesterday 12:01:23 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)