2009-07-01 7 views
1

Quelqu'un peut-il s'il vous plaît me suggérer comment nous pourrions configurer l'envoi de mails à travers nant.I avait même traversé le lien, mais je n'étais pas insatisfait.nant questions de courrier

Merci et salutations Maddy

Répondre

1

Quelque chose comme ceci est ce que vous utilisez.

<target name="sendmail"> 
    <mail 
     from=“[email protected]“ 
     tolist=“${distribution_list}“ 
     subject="${mailsubject}" 
     mailhost="${smtpServer}" 
     message="${mailbody}" 
     verbose="true" 
    > 
     <attachments> 
      <include name="${buildroot}/build.log" /> 
     </attachments> 
    </mail> 
</target> 
+0

Merci beaucoup andrew..Its fonctionne bien maintenant –

0

Voici un fichier de construction de l'échantillon. La solution n'est pas très élégante mais ça marche. Tout ce qu'il fait est de se connecter un fichier et avant d'envoyer l'email vider et en faire une copie pour l'attacher dans l'email.

Remarque: il existe des liens d'aide dans le code que j'ai utilisé lors de l'écriture de mon propre fichier de construction.

<description>Sample Build Scripts</description> 


<property name="nant.onsuccess" value="success" /> 
<property name="nant.onfailure" value="failure" /> 
<property name="tolist" value="[email protected]" /> 
<property name="cclist" value="[email protected]" /> 
<property name="emailsubject" value="" /> 


<target name="build" depends="init"> 

    YOUR ACTUAL BUILD CODE GOES HERE 

</target> 





<target name="init"> 

    <echo> 
    ----------------------------------------------------------------------------------------------------------------- 
    TASK : INITIALIZE 
    ----------------------------------------------------------------------------------------------------------------- 
    </echo> 

    <loadtasks assembly="nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" />  
    <!-- http://www.basilv.com/psd/blog/2007/how-to-add-logging-to-ant-builds --> 
    <tstamp>    
     <formatter property="timestamp" pattern="yyMMdd_HHmm"/> 
    </tstamp> 

    <property name="build.log.filename" value="build_${timestamp}.log"/> 

    <echo message="build.log.filename: ${build.log.filename}" /> 

    <record name="${build.log.dir}/${build.log.filename}" action="Start" level="Verbose"/>   

    <echo message="Build logged to ${build.log.filename}"/> 

    <echo message="Build Start at: ${datetime::now()}" /> 

</target> 


<!--http://www.mail-archive.com/[email protected]/msg02485.html--> 
<target name="success" depends="successresult,sendemail">  
    <echo>${emailsubject}</echo> 
</target> 

    <!--http://www.mail-archive.com/[email protected]/msg02485.html--> 
<target name="failure" depends="failureresult,sendemail"> 
    <echo>${emailsubject}</echo>   
</target> 


<target name="successresult" > 
    <echo> 
     BUILD FAILED . CHANGE SUBJECT 
    </echo> 
    <property name="emailsubject" value="Web Integration DEV Build : SUCCESS !!!" />    
</target> 


<target name="failureresult" >  

    <echo>  
    BUILD FAILED . CHANGE SUBJECT  
    </echo> 
    <echo message="Task Start at: ${datetime::now()}" /> 

    <property name="emailsubject" value="Web Integration DEV Build : FAILED !!! :)" /> 
</target> 


<target name="sendemail" > 

    <echo>  
    ----------------------------------------------------------------------------------------------------------------- 
    SENDING EMAIL 
    ----------------------------------------------------------------------------------------------------------------- 

    </echo> 
    <echo message="Task Start at: ${datetime::now()}" /> 

    <echo>${emailsubject}</echo>  
    <echo>Sending Email</echo> 
    <echo>Attaching File : ${build.log.dir}/email_${build.log.filename}</echo> 
    <echo>Attaching File : ${path.vsshelper.log}/logs/email_${build.log.getlistoffiles}</echo> 

    <!-- Flush is very important before you copy --> 
    <record name="${build.log.dir}/${build.log.filename}"  action="Flush" level="Verbose"/> 
    <sleep milliseconds="1000" /> 
    <!-- make a copy --> 
    <copy file= "${build.log.dir}/${build.log.filename}" tofile="${build.log.dir}/email_${build.log.filename}" /> 

    <mail 
      from="${email.from}" 
      tolist="${email.to}" 
      mailhost="${email.host}" 
      message="${emailsubject}" 
      subject="${emailsubject}" 
    >    
      <attachments> 
       <include name="${build.log.dir}/email_${build.log.filename}" />     
       <include name="${path.vsshelper.log}/logs/email_${build.log.getlistoffiles}" /> 
      </attachments>    
    </mail> 

</target>