Aspose.Email FOSS for C++ एक MIT-लाइसेंस वाला, ओपन-सोर्स C++ लाइब्रेरी है जो Microsoft Outlook .msg फ़ाइलों और Compound File Binary (CFB) कंटेनरों के साथ काम करने के लिए है। CMake के माध्यम से हेडर शामिल करें और तुरंत ईमेल संदेशों को पढ़ना, बनाना और प्रोसेस करना शुरू करें, बिना Microsoft Outlook या किसी भी स्वामित्व वाले रनटाइम को स्थापित किए।
लाइब्रेरी दो स्तरों की पहुँच प्रदान करती है। निचले स्तर पर, cfb_reader और cfb_writer CFB बाइनरी कंटेनरों पर पूर्ण नियंत्रण देते हैं — डायरेक्टरी एंट्रीज़ को ट्रैवर्स करें, स्टोरेज नोड्स और स्ट्रीम डेटा को पढ़ें और लिखें, और कच्चे सेक्टर लेआउट का निरीक्षण करें। msg_reader और msg_writer CFB के ऊपर MSG फ़ॉर्मेट को संभालते हैं, MAPI प्रॉपर्टी स्ट्रीम्स, रिसिपिएंट टेबल्स, और अटैचमेंट सब-स्टोरेज को उजागर करते हैं। उच्च स्तर पर, mapi_message आपको नई संदेशों को शून्य से बनाने, विषय, बॉडी, रिसिपिएंट्स और अटैचमेंट्स को पढ़ने, और MSG और EML फ़ॉर्मेट के बीच रूपांतरण करने की अनुमति देता है।
यह लाइब्रेरी किसी भी प्लेटफ़ॉर्म पर C++17 कंपाइलर के साथ बनती है और इसका कोई बाहरी निर्भरता नहीं है, जिससे यह Windows, Linux, macOS, Docker कंटेनरों और एम्बेडेड सिस्टम्स के लिए उपयुक्त बनती है।
cfb_reader::from_file(), cfb_reader::from_stream(), or cfb_reader::from_bytes().storage_ids(), stream_ids(), and child_ids(), and navigate nested hierarchies with resolve_path().cfb_node::is_storage() and cfb_node::is_stream(), read timestamps via creation_time() and modified_time().cfb_document and serialize to bytes or file via cfb_writer::to_bytes() or cfb_writer::write_file()..msg files — direct CFB access enables forensic inspection and repair.msg_reader::from_file() or msg_reader::from_stream() and access the underlying MAPI property streams and attachment sub-storages.msg_document with msg_writer::to_bytes() or msg_writer::write_file().msg_document::major_version(), msg_document::minor_version(), and check strictness with msg_document::strict().msg_document::to_cfb_document()..msg files from archive directories and extract metadata or attachments.mapi_message::create(), then set subject, body, and HTML body via set_subject(), set_body(), and set_html_body().set_sender_name(), set_sender_email_address(), and set_sender_address_type() for the outgoing message.mapi_attachment::from_bytes() and mapi_attachment::from_stream(), and check for embedded messages via is_embedded_message().mapi_message::save() and reload with mapi_message::from_file() or mapi_message::from_stream()..eml file (RFC 5322 / MIME) into a full mapi_message object via mapi_message::load_from_eml().mapi_message back to MIME format with save_to_eml()..eml and .msg files to a single format.Open an Outlook MSG file from a stream and print the subject — no Microsoft Outlook required.
#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';
}
Build a complete email with sender, recipient, and attachment, then write it to both MSG and EML formats.
#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);
}