I have never used these objects before but I can tell you that you get the exception because you don't instantiate the 'msg' object:
Blob msg; <-- it is null so when you write this:
msg.setBytes(1,msgval) --> you get the exception
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
Online 3,258 posts
since Dec 2007