Mail Rules and GPG

I want to write an Applescript that can implemented as a rule in It will pass the message body to an external program (in this case gpg), get the results and then forward the email to a specified email address.

Are they any examples of something similar to this (such as scripting a Rule or passign a message body to external command line executable)?