In order to support iPhone OS 3.x and 4.0 I programmatically control MFMessageComposeViewController functionality like this (use it only if the OS version is 4.0 or above):
I was having the same problem, and solved it a different way:
On the Left hand-side of your XCode window,
If you scroll down to the Bulls Eye with "Targets" and expand that
Expand your
< control > + < click > on "Link Binary With Libraries"
Choose "Add" --> "Existing Frameworks"
Choose "MessageUI.framework" and click on "Add"
That should add the Message UI to your app, tell me if it works.