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

  • Spring with EMail Attachment + Velocity Templates

    Hi,

    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
    </bean>


    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)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

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