sendmessage function