Aspose.Email FOSS for C++ เป็นไลบรารี C++ แบบเปิดต้นฉบับที่ใช้ใบอนุญาต MIT สำหรับทำงานกับไฟล์ Microsoft Outlook .msg และคอนเทนเนอร์ Compound File Binary (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 containers, และระบบฝังตัว.
รุ่นองค์กรที่มีคุณลักษณะเพิ่มเติมมีให้บริการเป็น 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 — การเข้าถึง CFB โดยตรงทำให้สามารถตรวจสอบและซ่อมแซมเชิงนิติวิทยาศาสตร์ได้.msg_reader::from_file() หรือ msg_reader::from_stream() และเข้าถึงสตรีมคุณสมบัติ MAPI พื้นฐานและ sub-storages ของไฟล์แนบ.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 จากไดเรกทอรีเก็บถาวรและสกัดเมตาดาต้าหรือไฟล์แนบ.mapi_message::create(), จากนั้นตั้งหัวเรื่อง, เนื้อหา, และ HTML เนื้อหาผ่าน 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);
}