?
Solved

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

Posted on 2009-05-06
5
Medium Priority
?
522 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
We aren’t perfect, just like everyone else.  Check out the email errors our community caught and learn the top errors every email marketer should avoid.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 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