There are loads of templating engines out there. Velocity for example is a decent one.
Once you have your message sending it using JMS to a topic is pretty basic. See the JMS tutorial for how to do this. However, since you mention mail merge, is it really JMS you are looking for and not JavaMail?