How can I use an Applescript from within a program?
To use this (or any) script in a program like Apple Mail, you could create a service in Automator.

Launch the Automator program.

When it says Choose a type for your document, select Service and click Choose



In the top dialog, select Service receives no input in Mail.app (or, the name of your program, or any application if that's what you want).

You will insert one action: From the Utilities group, double-click Run AppleScript.



Select the text that says


  (* Your script goes here *)


and paste in the script you want to run. In your case, the script you want to paste is 

  tell application "Mail"
    set theSelection to selection
    set theMessage to item 1 of theSelection
    set theSubject to subject of theMessage
    tell application "Address Book"
        set theGroup to make new group with properties {name:theSubject}
    end tell
    set theRecipients to to recipients of item 1 of theMessage
    repeat with a from 1 to count theRecipients
        set theRecipient to item a of theRecipients
        tell application "Address Book"
            set theName to name of theRecipient
            tell application "Mail" to set theAddress to address of theRecipient
            set thePerson to make new person with properties {first name:name of theRecipient}
            make new email at end of emails of thePerson with properties {value:theAddress}
            add thePerson to theGroup
        end tell
    end repeat
    set theRecipients to cc recipients of item 1 of theMessage
    repeat with a from 1 to count theRecipients
        set theRecipient to item a of theRecipients
        tell application "Address Book"
            set theName to name of theRecipient
            tell application "Mail" to set theAddress to address of theRecipient
            set thePerson to make new person with properties {first name:name of theRecipient}
            make new email at end of emails of thePerson with properties {value:theAddress}
            add thePerson to theGroup
        end tell
    end repeat
    tell application "Address Book" to save
  end tell


Once you have done that, go to the File menu and click Save.

Give the service a name you will remember, like "Add Recipients to Group".

Then when you are in Mail, you can select a message or messages and go to the Mail menu in the menu bar, then the Services menu in the Mail menu, and select the service Add Recipients to Group.