Sigh. Actually I have just developed a JMS-backed email queue. Unfortunately I'm not free to give you the code or the design detail.
In JMS, you can queue (among other things) any Serializable object. So all you have to do is queue an object that knows how to populate the JavaMail Message object, or maybe an object that carries the various ids you mentioned and that can be used to generate the e-mail.
It's all pretty straightforward and you don't need to use any JMS wizardry; if you rummage around on the net you're bound to find simple examples of queuing and dequeuing messages. It gives you ease of use,
thread safety, and (if you use JMS's transactional capabilities) a guarantee that the e-mail will be sent out whatever happens.
You can use the JMS implementation built into the application server if your server has one, or an add-on implementation.
OpenJMS is a decent open source implementation backed by a relational database.
- Peter
[ April 10, 2002: Message edited by: Peter den Haan ]