3

Ant タスク送信メール - メール タイプは、ネストされた「添付ファイル」要素をサポートしていません。

私は Maven を使用して、TestNG を使用してテスト自動化スクリプトを実行しています。私は maven antrun プラグインを使用して、添付ファイルにテスト NG レポートを含む電子メールを送信しています。

残念ながら、添付ファイル付きのメールを送信できず、次のようなエラーが発生します

埋め込みエラー: mail> タイプは、ネストされた「添付ファイル」要素をサポートしていません。

ここに私の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> 
4

2 に答える 2

1

Java アクティベーション フレームワークと Java メール jar をクラスパスに追加する必要があります。Ant や Java は付属していません。ここからダウンロードできます。

2 つの jar ファイルをダウンロードして、ant クラスパスに追加すると、正常に動作するはずです。

ところで、Ant のドキュメントでは、 mail タスクのマニュアル ページでこれについて説明しています。

于 2012-11-14T17:55:11.610 に答える
0

Maven postman プラグインは私にとってはうまくいきました。助けてくれてありがとう。

  <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@email.com</receiver>
                        </receivers>
                        <fileSets>
                            <fileSet>
                                <directory>${basedir}/target</directory>
                                <includes>
                                    <include>**/emailable-report.html</include>
                                   <!-- <include>**/*.zip</include> -->
                                </includes>
                            </fileSet>
                        </fileSets>
                    </configuration>
                </execution>
            </executions>
        </plugin>
于 2012-11-15T09:59:28.853 に答える