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 类路径中,它应该 工作正常。
关于email - ant 任务发送电子邮件 - 邮件类型不支持嵌套的 "attachments"元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13384284/