Ant mail task - Issue in sending mail with attachm

2019-05-07 02:30发布

问题:

When I tried using ant mail task, it doesnot seem to work when it comes sending mail with attachments. The problem I am currently facing is, it sends the attachment(s) content in the body of the email, rather than as attachement, even though verbose output displays as, it is sending with attachment. As initially it complained for missing jars, I added mail.jar & activation.jar. Here is the snippet which I tried:

<mail mailhost="mailHost.com" messagemimetype="text/html" subject="Test report" >
<from address="mymaild-addr@somedomain.com"/>
<replyto address="mymaild-addr@somedomain.com"/>
<to address="mymaild-addr@somedomain.com"/>
<message> Attached is sample report </message>
<attachments>
<fileset dir="${myRequiredDirectory}">
  <include name="Test.txt"/>
  <include name="Calls.txt"/>
</fileset>
</attachments>
</mail>

And I get

[mail] Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer
[mail] Failed to initialise UU mail: Class org.apache.tools.ant.util.ClasspathUtils can not access a member of class org.apache.tools.ant.taskdefs.email.UUMailer with modifiers ""
[mail] Sending email: Test report
[mail] Sent email with 2 attachments

回答1:

It worked fine, after adding another dependent jar 'ant-javamail.jar'.



标签: email ant