Description: This script will add a address to a ”Killfile”
Requirement: Mac OS 10.2+, Eudora 5+

-- Script Start
(*
  Add address to Killfile nickname version 1.0b2 for Mac OS X
  2002-05-31 by Fredrik Jonsson <mailto(colon)fredrik(at)combonet(dot)se>
  home page <http://xdeb.org/wiki/AppleScript>
 
  mgrep OSAX is used to parse the from address
  <http://www.bekkoame.ne.jp/~iimori/sw/mgrepOSAX.html>
 
  Thanks to Christopher Stone and Andrew Starr who gave me
  very good examples to work from. Without them, I would not
  have managed to put together this script.
 
*)
 
property nickfile : "Killfile" -- Set this to the name of your Adress Book, default is "Eudora Nicknames"
property theNick : "_killfile" -- Set this to the name you want for your killfile, defult is "Killfile"
 
tell application "Eudora"
 
  -- Check if the nickname exist, if not it will create it
  if not (exists nickname theNick) then
    make nickname at end of nickname file nickfile with data theNick
  end if
 
  -- Check if a message is selected
  try
    field "from" of front message
  on error e
    tell me to display dialog return & e & "
(A message must be selected)" buttons {"OK"} ¬
      default button 1 with icon 2
    return
  end try
 
  -- Extract the address from the selected message
  set fFld to field "from" of front message
  set fFld to item 1 of subMatchStr of (mgrep fFld regex "From: ?(.*)")
  if fFld is not "" then
    if fFld contains "<" then
      set theAdrs to item 1 of subMatchStr of (mgrep fFld regex "<(.+)>")
    else
      -- Some messages have only the adress in the From: field
      if fFld contains "@" then
        set theAdrs to fFld
      end if
    end if
  else
    tell me to display dialog return & ¬
      "There is no From address in this message" buttons {"OK"} ¬
      default button 1 with icon 2
    return
  end if
 
  -- Not required but makes saving the window unnecessary.
  try
    if exists of window "Address Book" then
      close window "Address Book"
    end if
  on error e
    tell me to display dialog return & e & "
(The script has been cancelled)" buttons {"OK"} ¬
      default button 1 with icon 2
    return
  end try
 
  -- Finally, add the address to the nickname
  set comma to ","
  set theOldAdrs to addresses of nickname theNick of nickname file nickfile
  set addresses of nickname theNick of nickname file nickfile to (theOldAdrs & comma & theAdrs)
 
  -- Uncommet this lines it you want to move the message to the trash
  set status of front message to already read
  move front message to the end of the mailbox "Spam?"
 
end tell
-- Script Stop