Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Apple Script to delete mail based on a pattern found in the mail.

Posted on 2009-05-06
5
Medium Priority
?
524 Views
Last Modified: 2013-12-26
I can tell Apple Scripting is what i need to help process the mail that I need.  (Hundreds a day)

Can someone help me produce a script that looks for a pattern and if found, deletes the message?

The pattern is:
".



    Army " 

Yes, the hard returns and all.

A normal (keeper) message may contain the word Army, but if there is a period, then the hard coded returns, then the word Army, I want to delete the message.

Best way to do that is.......

Thanks!
0
Comment
Question by:TIgerV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 

Author Comment

by:TIgerV
ID: 24320264
Delete or Purge.  This is an IMAP mailbox.
0
 
LVL 5

Accepted Solution

by:
AGoodKeenMan earned 2000 total points
ID: 24334441
Ok, try this. Save the script into ~/Library/Scripts/Applications/Mail/. You will need to setup a rule that runs the script on all messages, preferably one that presorts the messages for the word "Army" and a period. Also I have found that the script would not work when I had Safari 4 beta installed.
-- 08/05/09 Script to sort incoming messages for the string ".\n\n\n\nArmy"
 
using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			set searchString to ".
 
 
 
Army"
			repeat with theMessage in theMessages
				set theAccount to the account of the mailbox of theMessage
				if content of theMessage contains searchString then
					set mailbox of theMessage to mailbox "Trash" of theAccount
					set read status of theMessage to yes
				end if
			end repeat
		end tell
	end perform mail action with messages
end using terms from

Open in new window

0
 

Author Comment

by:TIgerV
ID: 24334656
Thank you.  
I will try this one this afternoon.

Tony
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The new Gmail Phishing Scam going around is surprising even the savviest of users with its sophisticated techniques.
Article by: Dermot
The life of crime is over for 22 year-old Christian Ian Salvador, a student from Isabela State University in the Philippines.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question