Apple Event: May 7th at 7 am PT

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

Outlook 365 Mac, how to ‘nuke’ messages

In outlook 2011 I had an apple script, that would nuke messages, means permanently delete them from any folder in outlook.


I also had a keyboard shortcut assigned to it and so it made dumping spam and other uninteresting stuff really easy without putting them first in the trash and next remove them from the trash.


The script no longer works in 365 (mac version), so I am looking for a new solution. Does anybody have one?


FYI here is the script I have:


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


MacBook Pro Retina

Posted on Feb 12, 2021 9:05 AM

Reply
Question marked as Best reply

Posted on Feb 12, 2021 11:41 AM

Here is an example of how Outlook allows setting up "Rules" -- this one deletes mail messages that are more than 14 days old that are in the Trash.



Outlook allows access to Rules from the Tools menu or from its Preferences.


You can also create a folder called "180" and put things in there that you specify are to be deleted after 180 days through a different Rule. It's all automatic, fully supported by MS-Office, no need to run scripts, maintain scripts that stop working over different versions of Office, etc.

Similar questions

12 replies
Question marked as Best reply

Feb 12, 2021 11:41 AM in response to ChangeAgent

Here is an example of how Outlook allows setting up "Rules" -- this one deletes mail messages that are more than 14 days old that are in the Trash.



Outlook allows access to Rules from the Tools menu or from its Preferences.


You can also create a folder called "180" and put things in there that you specify are to be deleted after 180 days through a different Rule. It's all automatic, fully supported by MS-Office, no need to run scripts, maintain scripts that stop working over different versions of Office, etc.

Feb 16, 2021 2:08 AM in response to steve626

steve626 wrote:

The rule kicks in automatically. You don't need to run it manually (I don't even know how to do that).



It appears not to do that in my case.  So, question is why?


When you "delete" a message, where do they go? Is it "Deleted Items (On My Computer)" or another "Deleted Items" (Trash)? In Outlook, there are sometimes multiple Trash cans under different headings, you need to make sure the rule is emptying the right one.


they go to "Deleted Items (On My Computer)". this is also the only folder I find for deleted items.



Are you using IMAP or POP for your email?


POP.



The MS-Office implementation has some quirks, it is not perfect.


Indeed, it always did from version 98 upwards.


For instance, after running my rule I noticed a small number (a few) of older emails still in the Trash that had not been deleted.


Stuff is not deleted here too. You say "after running my rule'. Does this mean you run it manually or? Or?


I also have one for the send folder.  See pic.

 

180 days back from now is Aug. 20.  (see here https://www.convertunits.com/dates/daysfromnow/-180) I have mails in there that are more than 200 days old.

 

So somehow it is not working. 





Feb 12, 2021 10:52 AM in response to steve626

That is an option, where do I find instructions as to how to do this?


However I still like to have the script. See rules (unimportant her as to why) oblige me to keep 180 days of email of certain categories. This makes the files of Outlook pretty large.


Therefore I like to be able to nuke all the non important stuff on the spot in one full swoop.

Feb 12, 2021 1:04 PM in response to ChangeAgent

You need to create a new rule that has does the things you want. The Edit Rules ... selection allows you to edit existing rules or to create new ones. If you set them up right, they do work, I use the one I showed you and it does work. I have other rules that automatically move certain emails (with a certain text string in the subject part of the email) into separate folders where I can look at them later.

Feb 12, 2021 11:54 PM in response to steve626

OK Thanks, and good morning Steve.


The only deference I see between your rule and mine is that mine has the box enabled ticked. Does it not need to be ticked to work?


So when does your rule kick in or is activate? Manual? Automatically? Or?


See I have messages that are over 180 days old and they do not get deleted at present.


PS.

And anybody reading with us do you have a solution for my script?

Feb 14, 2021 9:04 PM in response to ChangeAgent

Yes, it needs to be ticked "enabled" to run. Mine was running and working but I recently unticked it because our MS-Exchange server has started automatically deleting files in the Trash when older than 7 days, so my 14 day rule was no longer needed.


I did notice that your script is aimed at the Deleted Items folder that is On My Mac, but I think you need to also have one for the Deleted Items folder that is on the Exchange server, not just the local Deleted Items (On My Mac). Otherwise those ones won't be deleted and your rule won't accomplish what you want.

Feb 15, 2021 9:38 AM in response to ChangeAgent

The rule kicks in automatically. You don't need to run it manually (I don't even know how to do that).


When you "delete" a message, where do they go? Is it "Deleted Items (On My Computer)" or another "Deleted Items" (Trash)? In Outlook, there are sometimes multiple Trash cans under different headings, you need to make sure the rule is emptying the right one.


Are you using IMAP or POP for your email? If it is IMAP, your rule as shown is is emptying the "On My Computer" Trash but that's not the right one for IMAP. It might be the right one for POP. Test by seeing which Trash your deleted emails are moved to when you delete them and then make sure that the rule is emptying the correct one, or ones (after 180 days). This can also be more complicated if you have multiple email accounts and providers, but should still work.


The MS-Office implementation has some quirks, it is not perfect. For instance, after running my rule I noticed a small number (a few) of older emails still in the Trash that had not been deleted.



Feb 16, 2021 7:28 PM in response to ChangeAgent

Yes, it looks like your rules are not being applied properly. I believe this is a Microsoft Office issue, not a Mac issue. I may look into this in the Microsoft user discussions on Microsoft's web site. One thing that I recall reading about was to clear out potentially corrupted rules by delete all existing rules, then quitting Outlook, and then to re-enter them.


On my version of Outlook, I can run a rule manually by selecting messages (e.g. selecting all messages in the Trash) and then


Message =>Rules=>Apply => (Select the rule to apply to those messages) => Apply All


I think you can also select folder instead of individual messages.


It may also be that the rules, when created, only apply to future messages, not existing ones, unless you manually apply them as indicated above.



Feb 17, 2021 1:15 AM in response to steve626

Morning Steve, thanks.


I have been assuming all along this is a MS problem. Yes if you find anything elsewhere I like to hear. I have not found anything help-full as of today.


I tried your suggestion: Message =>Rules=>Apply => (Select the rule to apply to those messages) => Apply All

it worked on the deleted files folder not the sent folder.


I also thought they might only apply to messages that were created when the rule was. but having it work on one rule should rule that out.

Outlook 365 Mac, how to ‘nuke’ messages

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