I want to learn how to write Scripts!
Then might I suggest that you begin with the following links (in the specified order):
1. [AppleScript: The Language of Automation|http://www.macosxautomation.com/applescript>
2. [Beginner’s Tutorial: The First Step|http://www.macosxautomation.com/applescript/firsttutorial/index.html]
3. [Essential Sub-routines: Overview|http://www.macosxautomation.com/applescript/sbrt/index.html]
4. [AppleScript Language Guide|http://developer.apple.com/mac/library/documentation/AppleScript/Conceptu al/AppleScriptLangGuide/introduction/ASLR
intro.html#//appleref/doc/uid/TP40000983-CH208-SW1]
Would you mind sharing what all this code means to help out a rookie?
The first two and last two lines of the script come from an example script you can find at /Library/Scripts/Mail Scripts/Rule Actions/Sample Rule Action Script.scpt.
For the repeat block, see [repeat with loopVariable (in list)|http://developer.apple.com/mac/library/documentation/AppleScript/Conceptu al/AppleScriptLangGuide/reference/ASLR
control_statements.html#//appleref/doc/uid/TP40000983-CH6g-128481].
For the part of the script which gets the link from the current message, see [offset|http://developer.apple.com/mac/library/documentation/AppleScript/Concep tual/AppleScriptLangGuide/reference/ASLR
cmds.html#//appleref/doc/uid/TP40000983-CH216-SW24].
For the part of the script which gets the name of the PDF file, see [text item delimiters|http://developer.apple.com/mac/library/documentation/AppleScript/Con ceptual/AppleScriptLangGuide/conceptual/ASLR
fundamentals.html#//appleref/doc/uid/TP40000983-CH218-SW22].
For the part of the script which downloads the file, look for “path to” in the Standard Additions scripting dictionary and also for the “URL Access Scripting” dictionary. (Those dictionaries can both be opened from the File menu of the AppleScript Editor.)
Hope it can help. Gook luck.