Does that mean that you did this:
Put in a lot of logging of relevant variables so you know which lines get executed, and whether the variables have the values you think they should have.
? Post the output from it. Also make sure you set the "mail.debug" property to "true" before you call any JavaMail code - you'll get plenty of debugging output that way. Post that here as well.