परिचय

Aspose.Email FOSS for C++ एक नई ओपन-सोर्स लाइब्रेरी है जो Outlook MSG फ़ाइलों, RFC 5322 EML संदेशों, और उन Compound File Binary (CFB) कंटेनरों को पढ़ने, बनाने और परिवर्तित करने के लिए है, जिन पर MSG फ़ॉर्मेट बनाया गया है। यह C++17 में लिखी गई है, इसमें कोई बाहरी रनटाइम निर्भरताएँ नहीं हैं, और CMake के माध्यम से Linux, macOS, और Windows पर बिल्ड होती है — इसमें कोई COM निर्भरता नहीं है और न ही कोई प्लेटफ़ॉर्म-विशिष्ट कोड पाथ है।

Outlook MSG फ़ाइलें एंटरप्राइज़ इंटेग्रेशन कार्य में लगातार मिलती रहती हैं — आर्काइव पाइपलाइन, माइग्रेशन टूल, कंप्लायंस एक्सपोर्ट — लेकिन उन्हें Outlook के बिना पढ़ना आमतौर पर Windows पर COM ऑटोमेशन या किसी व्यावसायिक लाइब्रेरी की आवश्यकता होती थी। Aspose.Email FOSS for C++ आपको एक पोर्टेबल विकल्प देता है: दैनिक संदेश पढ़ने और निर्माण के लिए एक हाई-लेवल mapi_message क्लास, साथ ही नीचे-स्तर की msg_reader, msg_document, और cfb_reader क्लासेस, जब आपको आवश्यकता हो तो अंतर्निहित कंटेनर फ़ॉर्मेट तक सीधा पहुँच प्रदान करती हैं।

यह लाइब्रेरी MIT लाइसेंस के तहत C++17 स्रोत के रूप में वितरित की जाती है और एक प्रोजेक्ट में CMake सबडायरेक्टरी के रूप में जोड़ी जाती है, जिससे AsposeEmailFoss टारगेट उजागर होता है — कोई पैकेज मैनेजर रजिस्ट्रेशन और कोई प्रीबिल्ट बाइनरीज़ आवश्यक नहीं होते।


मुख्य विशेषताएँ

Outlook MSG फ़ाइलें पढ़ें

एक .msg फ़ाइल को msg_reader::from_file() या msg_reader::from_stream() के साथ खोलें। संदेश की स्टोरेज और स्ट्रीम्स तक सीधे पहुँचने के लिए, रीडर को msg_document में msg_document::from_reader() के साथ लपेटें।

#include "aspose/email/foss/msg/msg_reader.hpp"
#include "aspose/email/foss/msg/msg_document.hpp"
#include <filesystem>

namespace aef = aspose::email::foss;

auto reader = aef::msg::msg_reader::from_file(
    std::filesystem::path("message.msg"), /*strict=*/false);
auto document = aef::msg::msg_document::from_reader(reader);

प्रोग्रामेटिक रूप से संदेश बनाएं

mapi_message::create() विषय और बॉडी से एक नया इन-मेमोरी संदेश बनाता है। प्रेषक को सेट करें, प्राप्तकर्ताओं को जोड़ें, और बाइनरी या टेक्स्ट पेलोड को संलग्न करें, फिर save() के साथ सहेजें।

#include "aspose/email/foss/msg/mapi_message.hpp"
#include <filesystem>

namespace aef = aspose::email::foss;

auto message = aef::msg::mapi_message::create(
    "Quarterly status update", "Hello team,\n\nRollout summary attached.");
message.set_sender_name("Build Agent");
message.set_sender_email_address("build.agent@example.com");
message.add_recipient("alice@example.com", "Alice Example");
message.add_recipient("carol@example.com", "Carol Example",
    aef::msg::mapi_message::recipient_type_cc);
message.add_attachment("report.txt", std::vector<std::uint8_t>{'o', 'k'}, "text/plain");
message.save(std::filesystem::path("output.msg"));

MSG और EML के बीच रूपांतरण

mapi_message::save_to_eml() वर्तमान संदेश को RFC 5322 EML फ़ाइल के रूप में लिखता है, और mapi_message::load_from_eml() उसे वापस पढ़ता है। दोनों दिशाएँ विषय, प्रेषक, प्राप्तकर्ता और संलग्नकों को बरकरार रखती हैं, इसलिए संदेश Outlook के बिना MSG और EML के बीच स्थानांतरित हो सकता है।

auto message = aef::msg::mapi_message::from_file(
    std::filesystem::path("message.msg"), /*strict=*/false);
message.save_to_eml(std::filesystem::path("message.eml"));

auto restored = aef::msg::mapi_message::load_from_eml(std::filesystem::path("message.eml"));
restored.save(std::filesystem::path("restored.msg"));

संदेश गुण और संलग्नकों की जांच करें

लोड किया गया mapi_message अपने मानक हेडर फ़ील्ड को सीधे उजागर करता है — subject(), sender_name(), sender_email_address(), message_class(), और internet_message_id() — साथ ही recipients() और attachments() को mapi_recipient और mapi_attachment के वेक्टर के रूप में। उन MAPI फ़ील्ड्स के लिए जिनके लिए समर्पित एक्सेसर नहीं है, get_property_value() किसी भी प्रॉपर्टी को उसके common_message_property_id और property_type_code द्वारा पढ़ता है।

#include "aspose/email/foss/msg/mapi_message.hpp"
#include "aspose/email/foss/msg/common_message_property_id.hpp"
#include "aspose/email/foss/msg/property_type_code.hpp"
#include <iostream>

namespace aef = aspose::email::foss;

template <typename E>
constexpr auto to_underlying(E value) noexcept {
    return static_cast<std::underlying_type_t<E>>(value);
}

auto message = aef::msg::mapi_message::from_file(
    std::filesystem::path("message.msg"), /*strict=*/false);

std::cout << "Subject: " << message.subject() << '\n';
std::cout << "From: " << message.sender_name()
           << " <" << message.sender_email_address() << ">\n";
std::cout << "Recipients: " << message.recipients().size() << '\n';

for (const auto& attachment : message.attachments()) {
    std::cout << "- " << attachment.filename
               << " (" << attachment.mime_type << ", "
               << attachment.data.size() << " bytes)\n";
}

const auto display_cc = message.get_property_value(
    to_underlying(aef::msg::common_message_property_id::display_cc),
    to_underlying(aef::msg::property_type_code::ptyp_string));

निम्न-स्तरीय CFB कंटेनर पहुँच

MSG फ़ाइलें एक कॉम्पाउंड फ़ाइल बाइनरी (CFB) कंटेनर के भीतर संग्रहीत होती हैं — एक स्ट्रक्चर्ड-स्टोरेज फ़ॉर्मेट जो पुरानी Office बाइनरी फ़ॉर्मेट्स द्वारा भी उपयोग किया जाता है। cfb_reader कच्चे कंटेनर को खोलता है और उसकी डायरेक्टरी ट्री को सीधे उजागर करता है: storage_ids() और stream_ids() हर एंट्री को सूचीबद्ध करते हैं, directory_entry_count() कुल संख्या रिपोर्ट करता है, और header() कंटेनर की सेक्टर लेआउट लौटाता है। यह उपयोगी है जब आपको वह MAPI डेटा चाहिए जो mapi_message API नहीं दिखाता।

#include "aspose/email/foss/cfb/cfb_reader.hpp"
#include <iostream>

namespace aef = aspose::email::foss;

auto cfb = aef::cfb::cfb_reader::from_file(std::filesystem::path("message.msg"));
std::cout << "Directory entries: " << cfb.directory_entry_count() << '\n';
std::cout << "Storages: " << cfb.storage_ids().size() << '\n';
std::cout << "Streams: " << cfb.stream_ids().size() << '\n';

त्वरित प्रारंभ

अपने प्रोजेक्ट में लाइब्रेरी जोड़ें:

git clone https://github.com/aspose-email-foss/Aspose.Email-FOSS-for-Cpp.git
# CMakeLists.txt
add_subdirectory(Aspose.Email-FOSS-for-Cpp)
target_link_libraries(your_target PRIVATE AsposeEmailFoss::AsposeEmailFoss)

फिर एक संदेश बनाएं, उसे MSG के रूप में सहेजें, और इसे EML में राउंड-ट्रिप करें:

#include "aspose/email/foss/msg/mapi_message.hpp"
#include <filesystem>
#include <vector>
#include <cstdint>

namespace aef = aspose::email::foss;

int main() {
    auto message = aef::msg::mapi_message::create("Hello from C++", "Body text here");
    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");
    message.save(std::filesystem::path("hello.msg"));

    auto loaded = aef::msg::mapi_message::from_file(
        std::filesystem::path("hello.msg"), /*strict=*/false);
    loaded.save_to_eml(std::filesystem::path("hello.eml"));

    return 0;
}

समर्थित प्रारूप

फ़ॉर्मेटएक्सटेंशनपढ़ेंलिखें
Outlook संदेश (MSG).msg✓✓
EML (RFC 5322 / MIME).eml✓✓
संयुक्त फ़ाइल बाइनरी (CFB).cfb✓✓

ओपन सोर्स & लाइसेंसिंग

Aspose.Email FOSS for C++ MIT लाइसेंस के तहत जारी किया गया है। पूरा स्रोत aspose-email-foss/Aspose.Email-FOSS-for-Cpp पर उपलब्ध है, और वाणिज्यिक उपयोग बिना रॉयल्टी के अनुमति है। लाइब्रेरी को C++17 कंपाइलर और CMake 3.26 या उसके बाद के संस्करण के अलावा कोई रनटाइम निर्भरताएँ नहीं हैं।


शुरूआत

संबंधित संसाधन