Jul 5th, 2012, 01:31 AM
Spring with EMail Attachment + Velocity Templates
I am very new person to Java and using NetBeans. Previous guy who worked here has created basic framework for WebApps.
I have to create a generic mail manager which can send email. This has to use the text and html templates the way it setups under Velocity Engine. I have got all the libraries required for this development. (As far as I can tell)
I have written some classes based on reading books. But it is giving error while I am trying to run that.
I have attached all the code. I have created applicationContext-mail.xml and imported that in applicationContext.xml using below line.
my applicationContext-mail.xml is as below
<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailS enderImpl" >
<property name="host" value="***********"/> --******* is my mail host
I have attached the vm (Velocity Templates) and the java classes which I used.
I am scheduling TestMailManager.java to test whether it sends the email or not.
The error I am getting is somewhere in MailManagerImpl.java and it is because of the below line.
MimeMessage message = javaMailSender.createMimeMessage();
Not sure why it would have error. The error is below
Exception in thread "Timer-4" java.lang.NullPointerException
at com.warnermusic.mail.service.impl.MailManagerImpl. sendMail(MailManagerImpl.java:66)
at com.warnermusic.wis.util.TestMailManager.run(TestM ailManager.java:55)
I would really appreciate your help. I need this working as I am not really sure what has gone wrong.
Tags for this Thread