- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 04:56 AM
I'm trying to delete all outbox emails with a ready state. I want to do some testing with a few users without it sending everyone in the company emails since this was a clone from PRD. Any assistance would be greatly appreciated. I tried to via Tables & Columns but there is no "delete all records" option for the Email table.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 05:50 AM
Yes, you can add any user you want and they will all receive the email. The property is set to prevent test data to be send to people not knowing it is test data, which could lead to huge issues. Kudos you thought about deleting the email box first. I have seen differently over time which lead to lots of excuses.
Use the script shared by Ashish as background script.
By the way: if you have 16K emails in the outbox, you either have an issue on PROD (if it was a recent clone) or it's a cumulation over time. Best thing to do, is to get a test-mailbox and add that in the property, so the emails are always send out to that box. Put a rule on it to delete all received emails from the dev instance after a week and you will never have this issue again (somebody could check 'send email' by accident and not think about deleting the outbox content first).
Or put a scheduled job on it to clear the outbox every day, or something like that.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 05:38 AM
Thx! Is this a client script on the sys_email table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 05:45 AM
It's a fix script or background script.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 05:33 AM
Hi @jaubert ,
Please follow as suggested by @Mark Manders and @Community Alums
Use below updated code as shared by @Community Alums .
var grSysEmail = new GlideRecord('sys_email');
grSysEmail.addEncodedQuery("mailbox=outbox^state=ready");
grSysEmail.query();
grSysEmail.setWorkflow(false);
grSysEmail.deleteMultiple(); // deleteMultiple doesn't required result set iteration
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution