2009-07-01 8 views
1

Kann mir bitte jemand vorschlagen, wie wir das Senden von Mails über Nant konfigurieren konnte. Ich hatte sogar den Link durch, aber ich war nicht erfolgreich.nant mail issues

Danke und Grüße maddy

Antwort

1

So etwas ist, was würden Sie verwenden.

<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

Vielen Dank andrew..Its arbeiten jetzt fein –

0

Hier ist eine Beispiel-Build-Datei. Die Lösung ist nicht sehr elegant, aber es funktioniert. Alles, was es tut, ist eine Datei zu loggen und vor dem Senden von E-Mails bündig es und macht eine Kopie davon, um es in E-Mail anzuhängen.

Hinweis: Es gibt einige Hilfe-Links in Code, die ich beim Schreiben meiner eigenen Build-Datei verwendet habe.

<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>