Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Script to nuke messages in Outlook 2011

I have the following script for Entourage, and thought it would work under Outlook but it does not. it hangs on the first 'message'

Anybody know how to fix this?

FYI the script deletes a selected message immediately bypassing the trash.


on run
tell application "Microsoft Outlook"
if the class of the front window is message window then
set theMsg to the displayed message of the front window
my ProcessMsg(theMsg)
else
set theMessages to the selection
repeat with theMsg in theMessages
my ProcessMsg(theMsg)
end repeat
end if
end tell
end run

-- process the messages
on ProcessMsg(theMsg)
tell application "Microsoft Outlook"
move theMsg to deleted items folder
delete theMsg
end tell
end ProcessMsg

MBP, MM, MBP - 10.6 + Windooz XP on a hard partition

Posted on Mar 1, 2011 6:07 AM

Reply
Question marked as Best reply

Posted on Mar 1, 2011 12:37 PM

Outlook 2011 introduced a new command called "permanently delete". The old script tries to do a double-delete. It worked, but my Outlook client would hang for a long time before the script ended. Here's a new script that uses this new Outlook 2011 command:

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
10 replies
Question marked as Best reply

Mar 1, 2011 12:37 PM in response to ChangeAgent

Outlook 2011 introduced a new command called "permanently delete". The old script tries to do a double-delete. It worked, but my Outlook client would hang for a long time before the script ended. Here's a new script that uses this new Outlook 2011 command:

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

Apr 16, 2012 5:06 AM in response to Elfstones65

Elfstones65 wrote:


Also noticed today after installing the SP2 for the Office that the directory has changed...


to /Users/<user>/Library/Application Support/Microsoft/Office/Outlook Script Menu Items


Yeah noticed that too. (and the install made me realise I never answered your question) and had a bit of a headache it wanted to rebuild the database after the install and looped telling it could not etc. Thank God for backups.


I have an other question, to do with deleting. If I nuke or delete something from the trash and I do a search for it, it is still there. I have a tread about this here: http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macoutlook/deleted-me ssage-are-still-there-how-to-delete/dfad34d7-e8d7-4c0a-8f4e-52e458b43d82


Is this also the case for you? Or anybody for that matter have this problem.

Oct 5, 2012 7:49 AM in response to ChangeAgent

Thank you for this script, it has helped solve my desire to nuke the message from my Outlook 2011. I added a dialog to the script to ask for confirmation as sometime I little to quick with the keyboard shortcuts:


tell application "Microsoft Outlook"

set theMsgs to the current messages-- selected messages

try

set question to display dialog "Permanently Delete Message(s)?" buttons {"Yes", "No"} default button 2

set answer to button returned of question


if answer is equal to "Yes" then

repeat with theMsg in theMsgs


permanently deletetheMsg

end repeat

end if

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

Script to nuke messages in Outlook 2011

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.