First off, I am sorry to hear that this happened to you. You are correct that you certainly can try and offset any damages you incurred as a result of the company sending you the wrong materials. If your emails specifically state what materials you orderrd, and the materials you received do not comply with your order, then the company is liable for any damages they incurred as a result of its error.
It's important that you keep all of the emails to show specifically what you ordered. Also, it's important to keep all invoices of the materials you had to buy and use in order to finish the project. If the collection agency is trying to collect, make sure to send copies of the information and dispute the charge in writing. I would definitely send it "certified mail" with return receipt so you can prove that you disputed the claim.
It is important that you have a paper trail proving what you ordered (emails), the additional costs incurred (invoices from the additional purchases). Also, keep a record of any thing in writing where you gave them an opportunity to fix or cure their mistake or (defect or breach of contract).
Just to review, since you do not owe the money, then I would refuse to pay the collection costs. Also, make sure that you dispute it in writing so you have a paper trail. If the collection agency has all of the information, the collectors may not want to pursue it further. I would also make sure that they haven't already tried to put a "hit" on your credit report, if they have, then dispute the negative on your report with the credit agencies.
If there is anything else I can do for you, just let me know.