Unfortunately, there is currently no good way to run custom code when the phone sends a message. If you only need the number of messages sent, you can ask the content provider for content://sms/sent, but this only gives you the messages that were sent by the application that stores them there after sending (for example, the Android messaging application).
Related Questions