Sending Email with Ant
Tuesday 29 August 2006 - Filed under Code
I’ve been working on an Ant script to push file up to our development server – I’ll post this once I fix the code issue here but in the meantime I was also trying to get it to email me a summary of what it did. I got this working but it was throwing an error which bugged me. After endless digging on Google I finally found the solution and thought I’d post it here…
The error I was getting during my build:
Failed to initialise MIME mail: javax/mail/MessagingException
Turns out if you want to send email with Ant you need to add two JAR files:
mail.jar and exception.jar – these two JAR files can be found here:
Javamail
JavaBeans Activation Framework
Download these, extract them and find mail.jar (Javamail) and exception.jar (JAF).
Next I created a C:\jar directory. I can use this to store any additional jar files I may need in the future. Next you need to configure Eclipse:
- Open Eclipse. Open the Windows -> Prefences dialog.
- Select the Ant > Runtime node in the tree.
- Select the Classpath tab and the “Ant Home Entries (Default)” node.
- Click the “Add External JARS” button and add the two JAR files in the C:\jar directory.
Once I did this – no more errors during my build!
2006-08-29 » Jim Priest
18 February 2010 @ 4:53 am
Hi
Thanks for the above information – its clear and concise. I could not udnerstand some of the sites at all. I was wondering forthe longest time why my ant mailing broke down… cause I was not the original person who setup the environment … that’s the ant mail is working perfectly now… :-D
5 May 2010 @ 7:08 am
Hey Thanks….It Worked!!!