为C++是一个MIT授权的开源C++,用于与Microsoft Outlook.msg文件和复合文件二进制 (CFB)容器工作的库.通过CMake添加头条,立即开始阅读,创建和处理电子邮件消息而不需要安装微软Outlook或任何专有运行时间.
库提供两个访问层次.在低级,cfb_reader和 cfb_writer给你完全控制 CFB 二进制容器横向目录条款,阅读和写存储节点和流数据,并检查原始部门布局.msg_reader和msg_writer处理MSG格式的CFB上方,暴露MAPI属性流,接收表和附件子存放. 在高级别中, mapi_message让您从头开始创建新的消息,读主题,受体和文件,并在MS G 和EML格态之间转换.
该库建立在任何具有C++17编译器的平台上,并且没有外部依赖性,因此适用于Windows,Linux,macOS,Docker容器和嵌入式系统.
提供了具有额外功能的企业版为Aspose.Email for C++.
cfb_reader::from_file(), cfb_reader::from_stream()或cfb_reader::from_bytes()从一个文件路径,流,或者字节阵列上加载现有CF B容器.storage_ids(), stream_ids()和 child_ids()列出存储和流程,并使用 resolve_path().浏览嵌入式等级.cfb_node::is_storage()和 cfb_node::is_stream() 检测节點类型,使用creation_time()和modified_time()读取时间.cfb_document编程CFB文档,并通过 cfb_writer::to_bytes()或 cfb_writer::write_file() 将其串行到字节或文件中..msg 文件的容器格式.msg_reader::from_file()或 msg_reader::from_stream()打开Outlook MSG 文件,并访问底层MAPI属性流和附件子存储.msg_writer::to_bytes()或 msg_writer::write_file().从一个msg_document生成MS G文件.msg_document::major_version(), msg_document::minor_version()访问版本元数据,并使用msg_document::strict() 检验严格性.msg_document::to_cfb_document()从MSG文件中提取底层的CF B文档..msg 文件,并提取元数据或附件.mapi_message::create() 构建一个完整的电子邮件,然后使用set_subject(),set_body()和set_html_body()设置主题,体内和HTML体.set_sender_name(), set_sender_email_address()和 set_sender_address_type().mapi_attachment::from_bytes()和 mapi_attachment::from_stream() 载入字节或流的附件,并通过is_embedded_message()检查嵌入式消息.mapi_message::save()进行串行,然后使用 mapi_message::from_file()或 mapi_message::from_stream().mapi_message::load_from_eml() 将标准的.eml文件 (RFC 5322 / MIME) 分解成一个完整的 mapi_message 对象.save_to_eml() 将一个mapi_message 重新串行到 MIME 格式..eml和 .msg文件的混合档次标准化为一个格式.从流中打开 Outlook MSG 文件,然后印出主题.
#include <fstream>
#include <iostream>
#include "aspose/email/foss/msg/mapi_message.hpp"
int main()
{
std::ifstream input("sample.msg", std::ios::binary);
auto message = aspose::email::foss::msg::mapi_message::from_stream(input);
std::cout << message.subject() << '\n';
}
建立一个完整的电子邮件,发送者,收件人和附件,然后写入MSG和EML格式.
#include <fstream>
#include "aspose/email/foss/msg/mapi_message.hpp"
int main()
{
auto message = aspose::email::foss::msg::mapi_message::create("Hello", "Body");
message.set_sender_name("Alice");
message.set_sender_email_address("alice@example.com");
message.add_recipient("bob@example.com", "Bob");
message.add_attachment("note.txt", std::vector<std::uint8_t>{'a', 'b', 'c'}, "text/plain");
std::ofstream msg_output("hello.msg", std::ios::binary);
message.save(msg_output);
std::ofstream eml_output("hello.eml", std::ios::binary);
message.save_to_eml(eml_output);
}