1) It's a bit tricky as the internal storage of such things are not usually documented and can change. It's usually better to do that on the Mail side, via its rule system.
2) That can be done now via pattern matching on the contents and custom attributes.
1) Would someone mind posting a working Apple Scrip for that?
2) Not sure if you got my idea right. Let's say I have a line in a document "referencenumber: 1234567" and I need that number. How would I "read" this string and use that string in a file name?
Did you check the chapter on match patterns? Use "Contents contain match" with a match pattern. Use a custom attribute (described in the same chapter) to match the part of the text you want to re-use.