---
title: "ant学习笔记（七）"
author: "zzkathy"
date: "2008-01-11T16:05:00Z"
tags: []
slug: "ant"
draft: false
lastmod: "2008-01-11T16:05:00Z"
id: 158212
url: "https://zzkathy.iteye.com/blog/158212"
---

因为某些需求，今天尝试着使用ant中的&lt;mail&gt;task发送邮件，提醒相关人员build成功完成。脚本很简单，摘录ant中的example如下：

&lt;mail mailhost="somehost@xyz.com" mailport="25" subject="Build successful"  charset="utf-8"&gt;  
  &lt;from address="me@myist.com"/&gt;  
  &lt;to address="all@xyz.com"/&gt;  
  &lt;message&gt;some international text&lt;/message&gt;  
&lt;/mail&gt;

上午运行的时候没有什么问题，但是下午传到ClareCase上面以后就不行了，抛出如下异常：

\[mail] Failed to initialise MIME mail: javax.mail.Address 

Google了一下，发现只有一个人和喵喵有同样的问题，似乎是因为Library Dependencies的问题，然后look up了一下Ant User Manual，无语了——

**Note:** This task may depend on external libraries that are not included in the Ant distribution. See [Library Dependencies](http://ant.apache.org/manual/install.html#librarydependencies) for more information.

喵喵要什么时候才能仔细一点呢……

找到了问题，解决起来就简单了n\_n

mail.jar Mail task with Mime encoding, and the MimeMail task [http://java.sun.com/products/javamail/](http://java.sun.com/products/javamail/)

activation.jar Mail task with Mime encoding, and the MimeMail task [http://java.sun.com/products/javabeans/glasgow/jaf.html](http://java.sun.com/products/javabeans/glasgow/jaf.html)

在上述网址中下载第三方API，把其中的mail.jar和activation.jar添加到ANT\_HOME/lib下面，再运行ant脚本，就一切OK了~~