(* Mailman cancel script Copyright 2004, 2005 James Tittsler . This script may be freely redistributed, provided the copyright notices are included. http://www.OnJapan.net/mac/ Derived from "Get Source of Selected Messages", "Create New Message", and "Speak Sender and Subject" Apple sample code, which are Copyright 2002 and 2003 Apple Computer, Inc. *) (* This script sends cancel confirmations for the currently selected messages, each of which should be an approval message from Mailman. It also forms the basis of a variant that puts Approved: and list password as the first line of the body. 2004-05-18 2004-05-19 jwt scan from the bottom of each message 2005-10-13 jwt allow running as an ordinary script rather than just from the Mail Script menu *) using terms from application "Mail" on perform mail action with messages theSelectedMessages tell application "Mail" if (count of theSelectedMessages) is equal to 0 then display dialog "Please select one or more Mailman confirmation messages first, then run this script again." else repeat with eachMessage in theSelectedMessages set theSource to source of eachMessage if my cancelMessageWithSource(theSource) then delete eachMessage end if end repeat end if end tell end perform mail action with messages end using terms from on cancelMessageWithSource(theSource) set the paragraphList to every paragraph of theSource set requestAddress to "" set confirmLine to "" set i to length of paragraphList repeat while (requestAddress = "" or confirmLine = "") and i ³ 1 set thisParagraph to item i of the paragraphList if thisParagraph begins with "From: " then try set requestAddress to characters 7 thru -1 of thisParagraph as string end try else if thisParagraph begins with "Subject: confirm " then try set confirmLine to characters 10 thru -1 of thisParagraph as string end try end if set i to i - 1 end repeat tell application "Mail" set newMessage to make new outgoing message tell newMessage set visible to false make new to recipient with properties {name:my listName(requestAddress), address:requestAddress} set subject to confirmLine -- set content to "Approved: xyzzy" if requestAddress contains "-request" and confirmLine contains "confirm " then send return true else set visible to true end if end tell return false end tell end cancelMessageWithSource on listName(emailAddress) set lName to "" repeat with i from 1 to length of emailAddress set c to character i of emailAddress as string if c = "@" then set c to "-" set lName to lName & c end repeat return lName end listName -- If run as an ordinary script, instead of directly from the Scripts -- menu, it will call the default handler instead. using terms from application "Mail" on run tell application "Mail" to set sel to selection tell me to perform mail action with messages (sel) end run end using terms from