email - ant 任务发送电子邮件 - 邮件类型不支持嵌套的 "attachments"元素

标签 email ant task

Ant 任务发送电子邮件 - 邮件类型不支持嵌套的“附件”元素。

我正在使用 Maven 来运行使用 TestNG 的测试自动化脚本。我正在使用 Maven antrun 插件发送附件中包含测试 NG 报告的电子邮件。

不幸的是,我无法发送带有附件的电子邮件并收到错误信息

嵌入错误:邮件> 类型不支持嵌套的“附件”元素。

这是我的 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> 

最佳答案

您需要将java激活框架和java邮件 jar 添加到您的 类路径。 它们不随 Ant 或 Java 提供,可以下载 here

下载 2 个 jar,将它们添加到你的 ant 类路径中,它应该 工作正常。

顺便说一句,Ant 文档 tells你在手册上关于这个 mail task 的页面.

关于email - ant 任务发送电子邮件 - 邮件类型不支持嵌套的 "attachments"元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13384284/

相关文章:

wordpress - 让用户在注册时输入密码?

java - 如何在 apt/javac 命令行上指定一个 AbstractProcessor?

ant - 为什么在 "ant -?"目标中这样写 : [target [target2 [target3] . ..]]?

ant - 如何使用 Ant 和 YGuard 混淆我的 Web 应用程序 project.war?

c# - 如果正在运行则取消异步任务

ruby-on-rails - 如何编写使用 args 运行多个任务的任务?

email - 确认 PayPal 沙箱帐户电子邮件

email - 使用 Swift 发送 HTML 电子邮件

c# - Windows 任务调度程序 C#

python - 通过 python 应用程序通过 gmail 发送电子邮件