well, there are a few missing pieces of information that we would need to know before we can tell you how to accomplish this:
1) Is the code unique to each user? or is a generic code sent to everybody?
2) is there only one file that will be downloaded? or does the downloaded file change based on the code entered?