Announcement Announcement Module
No announcement yet.
Spring with EMail Attachment + Velocity Templates Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

    <import resource="applicationContext-mail.xml"/>

    my applicationContext-mail.xml is as below

    <bean id="velocityEngine"
    class="org.springframework.ui.velocity.VelocityEng ineFactoryBean"
    p:resourceLoaderPath="/templates/mail" />

    <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 to test whether it sends the email or not.

    The error I am getting is somewhere in 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(
    at java.util.TimerThread.mainLoop(

    I would really appreciate your help. I need this working as I am not really sure what has gone wrong.
    Attached Files