Thank you for your guidance and i would like to make this point clear that the intention is to get the problems solved and not to get the code, since from the previous replies we didn't actually get any solution for our problem, thats why finally I've asked for the sample code.
Please read How (not) to ask a question. Its hard to provide help when don't provide context and ignore questions in replies.
Comment on Re^3: Sample code for message capturing