2012-11-14 25 views
3

Ant任務發送郵件 - 郵件類型不支持嵌套的「附件」元素。ant任務發送郵件 - 郵件類型不支持嵌套的「附件」元素

我正在使用Maven使用TestNG運行測試自動化腳本。我正在使用maven antrun插件發送帶有測試NG報告的電子郵件。

可惜我不能發送電子郵件attachement並獲得誤差

嵌入式錯誤:郵件>類型不支持嵌套的「附件」元素。

,這裏是我的pom.xml

 <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.1</version> 
      <executions> 
       <execution> 
        <configuration> 
         <tasks> 
          <mail 
            tolist="" 
            from="" 
            subject="Report" 
            mailhost="" 
            mailport="" 
            user="" 
            password=""> 
           <message>Please find the Attached automation report. 
             Note: This is an automatic generated e-mail 
           </message> 
           <attachments> 
            <fileset dir="target"> 
             <include name="**/*.html"/> 
            </fileset> 
           </attachments> 
          </mail> 
          </tasks> 
        </configuration> 
        <phase>test</phase> 
        <id>SentEmail</id> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

回答

0

Maven郵差插件爲我工作得很好。感謝您的幫助。

<plugin> 
      <groupId>ch.fortysix</groupId> 
      <artifactId>maven-postman-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>send a mail</id> 
        <phase>test</phase> 
        <goals> 
         <goal>send-mail</goal> 
        </goals> 
        <inherited>false</inherited> 
        <configuration> 
         <from>xxxxxxxx</from> 
         <subject>Regression Report</subject> 
         <failonerror>true</failonerror> 
         <mailhost>xxxxx</mailhost> 
         <mailport>xxx</mailport> 
         <mailuser>xxxxxx</mailuser> 
         <mailpassword>xxxxx</mailpassword> 
         <htmlMessage>Please find the Attached automation report. 
          Note: This is an automatic generated e-mail</htmlMessage> 
         <receivers> 
          <receiver>[email protected]</receiver> 
         </receivers> 
         <fileSets> 
          <fileSet> 
           <directory>${basedir}/target</directory> 
           <includes> 
            <include>**/emailable-report.html</include> 
            <!-- <include>**/*.zip</include> --> 
           </includes> 
          </fileSet> 
         </fileSets> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
1

您需要的Java激活框架和Java郵件罐子添加到您的 類路徑。 他們不來與螞蟻或Java和可下載here

下載了2瓶,將它們添加到您的類路徑的螞蟻,它應該 做工精細。

順便說一下,您在關於mail task的手冊 頁面上的Ant文檔tells