Som Sarkar
Som Sarkar

Reputation: 289

How to send a rcord file as an email using ANT task

I have an ANT task which has a "record" section. The Task is -

<target name="validation">
 <record name="${tools.dir}/build-config/SPARQL/BuilLog.txt" action="start"/>
  <foreach target="javatask" param="queryFile">
    <fileset dir="${tools.dir}/build-config/SPARQL/Queries">
      <include name="*.rq"/>
    </fileset>
  </foreach>
 <record name="${tools.dir}/build-config/SPARQL/BuilLog.txt" action="stop"/>
</target>

When I am running the task it creates a text file called BuildLog.txt. Now I want this file to be emailed or to send an email with the records. How can I do that.

Upvotes: 1

Views: 2102

Answers (1)

CAustin
CAustin

Reputation: 4614

Ant has a built-in "mail" task: https://ant.apache.org/manual/Tasks/mail.html

You can send the file as an attachment:

<mail
    from="[email protected]"
    to="[email protected]"
    subject="Build Log"
    message="Here's the latest build log."
    files="${tools.dir}/build-config/SPARQL/BuilLog.txt"
/>

Or you can set the body of the Email as the contents of the file:

<mail
    from="[email protected]"
    to="[email protected]"
    subject="Build Log"
    messagefile="${tools.dir}/build-config/SPARQL/BuilLog.txt"
/>

Upvotes: 2

Related Questions