Aug/060
Sending Email with Ant
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!
Possibly Related:

The Sending Email with Ant by Jim , unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
No comments yet.
Sorry, the comment form is closed at this time.
No trackbacks yet.
