Forum Discussion
Permanently delete junk mail that has certain subject words
Hi Lorne54,
To permanently delete specific types of junk mail that are not caught by the default filters, you can set up a rule that handles these emails before they're classified as junk. Here's how you can do that:
Create a New Folder:
- In Outlook, right-click on your email account and choose "New Folder." Name it something like "Custom Junk."
Create a Rule:
- Go to the "File" tab and click on "Manage Rules & Alerts."
- Click "New Rule."
Start from a Blank Rule:
- Choose "Apply rule on messages I receive" and click "Next."
Set Conditions:
- In the "Which condition(s) do you want to check?" section, select "from people or public group" if you want to target specific senders or "with specific words in the recipient's address" to look for specific words in the email address.
- Follow the on-screen instructions to define your specific criteria. For example, you can add conditions to look for specific words in the subject line.
Specify the Action:
- In the "What do you want to do with the message?" section, select "move it to the specified folder."
- Then, click on the underlined "specified" link to choose the "Custom Junk" folder you created in step 1.
Add Exception (Optional):
- You can add exceptions if necessary, for instance, to ensure that not all emails with those specific words are deleted.
Finish Rule Setup:
- Give your rule a name, and make sure the rule is enabled. Click "Finish" to complete the rule setup.
This rule will move emails that meet the specified conditions to the "Custom Junk" folder. Since these emails will not be classified as junk by Outlook's built-in filtering, you can then manually review and permanently delete them from the "Custom Junk" folder. This way, you have more control over which emails are permanently deleted.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)
- Victor_IvanidzeNov 27, 2023Bronze ContributorUse this freeware: https://ivasoft.com/deleteitemsinjunkfolderflow.shtml as a base and modify it according your needs,
- Lorne54Nov 27, 2023Copper Contributor
Thanks for that. It probably does the trick but I decided to write my own code that I have copied below if anybody is interested. I wrote it in Delphi but the code is readable so anybody knowing C++ or other languages can probably work out what it is doing. An interesting fact is that I found out that all the junk I did not want to check could be deleted just by looking at the sender's email which was always blank ! This code comes with no guarantees so user beware:
procedure TAppts.DeleteJunk(Sender: TObject);
const
olMail = $0000002B; olFolderJunk = 23;
var
i, iNbMail: Integer;
Created: Boolean;
EmailSubject, EmailSender: String;
Outlook, Namespace, JunkFolder, Mail: variant;
begin
try
Outlook:=GetActiveOleObject('Outlook.Application') ;
Created := False;
except
Outlook:=CreateOleObject('Outlook.Application') ;
Created := True;
end;try
NameSpace := Outlook.GetNamespace('MAPI');
NameSpace.Logon;JunkFolder:= NameSpace.GetDefaultFolder(olFolderJunk);
iNbMail:= JunkFolder.Items.Count;for i:= iNbMail downto 1 do
begin
Mail := JunkFolder.Items[i];
if Mail.Class <> olMail then Continue;
EmailSender := String(Mail.SenderEmailAddress);
EmailSubject:= String(Mail.Subject);
if (EmailSender = '') or (Pos('Russian Girls', EmailSubject) > 0)
then Mail.Delete;
end;
finally
Outlook := Unassigned;
NameSpace := Unassigned;
JunkFolder := Unassigned;
Mail := Unassigned;
if Created then
begin
Outlook.Quit;
Created := False;
end;
end;
end;