Aspose.Email FOSS สำหรับ C++ เป็นไลบรารี C++ แบบเปิดที่มีสัญญาอนุญาต MIT สำหรับทำงานกับไฟล์ .msg ของ Microsoft Outlook และคอนเทนเนอร์ Compound File Binary (CFB) รวมถึงคอนเทนเนอร์ไบนารี CFB. รวมหัวไฟล์ผ่าน CMake และเริ่มอ่าน, สร้าง, และประมวลผลข้อความอีเมลได้ทันทีโดยไม่ต้องติดตั้ง Microsoft Outlook หรือรันไทม์ที่เป็นกรรมสิทธิ์ใดๆ.
ไลบรารีนี้ให้การเข้าถึงสองระดับ. ในระดับต่ำ, cfb_reader และ cfb_writer ให้การควบคุมเต็มรูปแบบเหนือคอนเทนเนอร์ไบนารี CFB — เดินทางผ่านรายการไดเรกทอรี, อ่านและเขียนโหนดเก็บข้อมูลและข้อมูลสตรีม, และตรวจสอบโครงสร้างเซกเตอร์ดิบ. msg_reader และ msg_writer จัดการรูปแบบ MSG บน CFB, เปิดเผยสตรีมคุณสมบัติ MAPI, ตารางผู้รับ, และซับสตอเรจของไฟล์แนบ. ในระดับสูง, mapi_message ให้คุณสร้างข้อความใหม่ตั้งแต่ต้น, อ่านหัวเรื่อง, เนื้อหา, ผู้รับ, และไฟล์แนบ, และแปลงระหว่างรูปแบบ MSG และ EML.
ไลบรารีนี้สร้างบนแพลตฟอร์มใดก็ได้ที่มีคอมไพเลอร์ C++17 และไม่มีการพึ่งพาภายนอก, ทำให้เหมาะสำหรับ Windows, Linux, macOS, คอนเทนเนอร์ Docker, และระบบฝังตัว.
รุ่นองค์กรที่มีคุณสมบัติเพิ่มเติมมีให้บริการในชื่อ Aspose.Email for C++.
cfb_reader::from_file(), cfb_reader::from_stream(), หรือ cfb_reader::from_bytes().storage_ids(), stream_ids(), และ child_ids(), และนำทางโครงสร้างลำดับชั้นที่ซ้อนกันด้วย resolve_path().cfb_node::is_storage() และ cfb_node::is_stream(), อ่านค่า timestamp ผ่าน creation_time() และ modified_time().cfb_document และแปลงเป็นไบต์หรือไฟล์ผ่าน cfb_writer::to_bytes() หรือ cfb_writer::write_file()..msg ไฟล์ การเข้าถึง CF B โดยตรงสามารถตรวจค้นและซ่อมแซมทางการทหารคดีได้.msg_reader::from_file() หรือ msg_reader::from_stream() และเข้าถึง MAPI เซอร์พลิเติมที่อยู่เบื้องหลังและการเก็บรองคู่มือ.msg_document ด้วย msg_writer::to_bytes() หรือ msg_writer::write_file().msg_document::major_version(), msg_document::minor_version() และเช็คความเข้มงวดด้วย msg_document::strict().msg_document::to_cfb_document()..msg ไฟล์จากกํากับการเก็บรักษาและถอด metadata หรือแนบ.mapi_message::create(), จากนั้นตั้งหัวเรื่อง, เนื้อหา, และ HTML body ผ่าน set_subject(), set_body(), และ set_html_body().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()..eml มาตรฐาน (RFC 5322 / MIME) เป็นวัตถุ mapi_message ที่ครบผ่าน mapi_message::load_from_eml().mapi_message กลับในรูปแบบ MIME ด้วย save_to_eml()..eml และ .msg เป็นรูปแบบเดียว.เปิดไฟล์ Outlook MSG จากสตรีมและพิมพ์หัวข้อ ไม่จําเป็นต้องใช้ Microsoft Outlook.
#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);
}