sendmessage implementation