HTML
JPG
PDF
XML
MSG
MSG
通过 Java 批量生成 MSG 格式报告
批量生成 MSG 电子邮件,无需 Outlook 或 Thunderbird。
如何使用 Java 生成 MSG 报告
为了创建 MSG 文件报告,我们将使用
该 API 是功能丰富、强大且易于使用的 Java 平台装配 API。您可以直接从以下位置下载其最新版本
并通过在 pom.xml 中添加以下配置,将其安装到基于 Maven 的项目中。
仓库
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
依赖
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-email</artifactId>
<version>version of aspose-email API</version>
<classifier>jdk17</classifier>
</dependency>
通过 Java 生成 MSG 报告的步骤
- 从 MailMessage 创建模板
- 为 Subject、To、From 和 HtmlBody 字段添加动态字段
- 使用 MailMessage 对象创建 TemplateEngine
- 创建数据源并映射到模板字段
- 使用 TemplateEngine.Instantiate 方法批量创建消息
- 以 MSG 格式保存消息
系统要求
Aspose.Email for Java 在所有主流平台和操作系统上均受支持。请确保您具备以下先决条件。
- 适用于 JSP/JSF 应用和桌面应用的 Microsoft Windows 或兼容的 Java 运行时环境的操作系统。
- 直接从 Maven 获取 Aspose.Email for Java 的最新版本。
批量生成 msg_Upper 消息 - C#
//create a new MailMessage instance as a template
MailMessage template = new MailMessage();
//add template field to subject
template.setSubject("Hello, #FirstName#");
template.setFrom(MailAddress.to_MailAddress("This email address is being protected from spambots. You need JavaScript enabled to view it."));
//add template field to receipt
template.getTo().addMailAddress(new MailAddress("#Receipt#", true));
//add template field to html body
//use GetSignment as the template routine, which will provide the same signment.
template.setHtmlBody("Dear #FirstName# #LastName#, Thank you for your interest in Aspose.Network.Have fun with it.#GetSignature()#");
//create a new TemplateEngine with the template message.
TemplateEngine engine = new TemplateEngine(template);
//fill a DataTable as data source
DataTable dt = new DataTable();
dt.getColumns().add("Receipt");
dt.getColumns().add("FirstName");
dt.getColumns().add("LastName");
DataRow dr;
dr = dt.newRow();
dr.set("Receipt", "Nancy.Davolio");
dr.set("FirstName", "Nancy");
dr.set("LastName", "Davolio");
dt.getRows().add(dr);
dr = dt.newRow();
dr.set("Receipt", "Andrew.Fuller");
dr.set("FirstName", "Andrew");
dr.set("LastName", "Fuller");
dt.getRows().add(dr);
dr = dt.newRow();
dr.set("Receipt", "Janet.Leverling");
dr.set("FirstName", "Janet");
dr.set("LastName", "Leverling");
dt.getRows().add(dr);
MailMessageCollection messages;
try{
//create the messages from the template and datasource.
messages = engine.instantiate(dt);
}catch (MailException ex){
//print exception
}
关于 Aspose.Email for Java API
Aspose.Email 是一个用于解析 Microsoft Outlook 和 Thunderbird 格式的解决方案。您可以轻松创建、操作、转换诸如 MSG、EMLX、EML 和 MHT 等电子邮件及存储格式。处理电子邮件附件、定制消息头以及实现 POP3、IMAP 和 SMTP 等网络协议以收发邮件变得更加容易。它是一个独立的 API,无需安装 Microsoft Outlook 或其他软件。MSG What is MSG File Format
MSG 是 Microsoft Outlook 和 Exchange 用于存储电子邮件、联系人、约会或其他任务的文件格式。这类消息可能包含一个或多个电子邮件字段,如发件人、收件人、主题、日期和正文,或包含联系信息、约会详情以及一个或多个任务规格。构成 Message 对象的属性也包含在 MSG 文件中。MSG 文件包含标题、主消息正文和以纯 ASCII 文本形式的超链接。MSG 文件也适用于需要 Microsoft 消息应用程序编程接口(MAPI)的程序。
Read More