Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rate Thread Display Modes
Old 11-28-2005, 07:57 AM   #1
Brian Kendig
Prospect
 
Join Date: Oct 2003
Posts: 23
Using Automator to report spam?

Is it possible to use Automator to report spam to spam@mac.com? Right now, for each email, here's what I have to do by hand:

- press Command-Option-U to show all the headers for a message
- press Command-A to select the entire message text
- click the Forward button
- type 'spam@mac.com' in the To: field
- click the Send button
- press Delete to delete the original message

Is there a way to automate these steps with Automator (or in any other way), so that I can select an email message and click one button and have the spam reported and deleted?
Brian Kendig is offline   Reply With Quote
Old 11-28-2005, 09:41 AM   #2
mark hunte
MVP
 
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
save this in the Mail applescript menu. ( Or use it in Automator ) select the single mail. and run it.
I only did this for single mail selection but it can be changed for multi.

Code:
tell application "Mail"
	set selectionMessage to selection
	set theMessages to item 1 of selectionMessage
	set the_headers to all headers of theMessages as string
	set the_content to content of theMessages
	set theBody to the_headers & return & return & the_content
end tell
set theSubject to "this is spam"
set theAddress to "spam@mac.com"
tell application "Mail"
	set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
	tell newMessage
		
		set visible to true
		
		make new to recipient at end of to recipients with properties {address:theAddress}
		send
	end tell
	
end tell
mark hunte is offline   Reply With Quote
Old 11-28-2005, 11:15 AM   #3
Brian Kendig
Prospect
 
Join Date: Oct 2003
Posts: 23
Thank you so much for posting this! I'm going to give it a try!

I don't know AppleScript - is it simple to modify so that I can select a bunch of messages and have them all reported one-by-one with just a single run of the script?
Brian Kendig is offline   Reply With Quote
Old 11-28-2005, 11:21 AM   #4
mark hunte
MVP
 
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
I will have a look when I get home in a bit..
mark hunte is offline   Reply With Quote
Old 11-28-2005, 12:39 PM   #5
mark hunte
MVP
 
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
This should do it. Take not of the comments inside, there is an option
to choose which sending account you use.

Code:
tell application "Mail"
	set selectionMessage to selection
	set counter to 0
	set mail_number to count messages in selectionMessage
	repeat with theMessages in selectionMessage
		set counter to counter + 1
		set theMessages to item counter of selectionMessage
		
		set the_headers to all headers of theMessages as string
		set the_content to content of theMessages
		set theBody to the_headers & return & return & the_content
		
		set theSubject to "This is spam"
		set theAddress to "spam@mac.com"
		
		(*
Remove every thing between the (* and *) apart from line -> set theSender to "youmailaddreshere@mac.com" <-
Put you prefered account email address to send from in the address below.
Also look further down and remove the -- from the line -> set sender to theSender <-


     set theSender to "youmailaddreshere@mac.com"
	 
*)
		
		set the SenderAccount to ""
		tell application "Mail"
			set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
			tell newMessage
				
				set visible to false
				--set sender to theSender
				make new to recipient at end of to recipients with properties {address:theAddress}
				send
			end tell
		end tell
	end repeat
	
end tell
mark hunte is offline   Reply With Quote
Old 11-30-2005, 07:55 AM   #6
Brian Kendig
Prospect
 
Join Date: Oct 2003
Posts: 23
That's awesome! Works great! Thank you so much! :-D
Brian Kendig is offline   Reply With Quote
Old 12-06-2005, 10:15 AM   #7
veshman
Prospect
 
Join Date: Oct 2002
Posts: 4
Thank you SOOOO much!!

Mark,

thank you SOO much for writing this script, as well as to the original poster for asking for the EXACT thing I was looking for.

i'm very new to applescript and was trying to give this a go myself for about 3 hours last night and didn't really come close

I was trying to use the "forward" command and wasn't getting anywhere, and I still hadn't really figured out how to show the full headers since the default forward does not include the full headers.

I added a "delete selectionMessage" command just before the penultimate "end tell" ... eg:

make new ....
send
end tell
delete selectionMessage
end tell
end repeat
end tell


this deletes the spam so i get to spend even less time with that crap! thanks!

Bhavesh Patel

Last edited by veshman; 12-06-2005 at 06:39 PM.
veshman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 04:43 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.