Getting Started

Getting Started with Aspose.Email FOSS for C++

Welcome to Aspose.Email FOSS for C++, a free, MIT-licensed C++ library for reading, creating, and writing Outlook MSG files and Compound File Binary (CFB) containers. This guide takes you from a fresh C++ project to working with MSG files in minutes.


Prerequisites

RequirementDetail
CompilerC++17 or later (GCC 9+, Clang 10+, MSVC 2019+)
Build systemCMake 3.26 or later
OSWindows, macOS, or Linux
DependenciesNone

Installation

Clone the repository and add it as a CMake subdirectory:

git clone https://github.com/aspose-email-foss/Aspose.Email-FOSS-for-Cpp.git

In your CMakeLists.txt:

add_subdirectory(Aspose.Email-FOSS-for-Cpp)
target_link_libraries(your_target PRIVATE AsposeEmailFoss::AsposeEmailFoss)

Verify with a minimal program:

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

int main()
{
    auto message = aspose::email::foss::msg::mapi_message::create("Test", "Hello");
    std::cout << message.subject() << '\n';
    // Output: Test
}

See the Installation Guide for detailed project setup.


What You Can Do

Once set up you can immediately:

  • Read MSG files with mapi_message::from_stream() or mapi_message::from_file() — access subject, body, sender, recipients, and attachments
  • Create MSG messages from scratch with mapi_message::create() — set all fields, add recipients and attachments, then serialize with save()
  • Convert between MSG and EML with load_from_eml() and save_to_eml()
  • Inspect CFB binary containers with cfb_reader — traverse storages and streams, resolve paths, read raw bytes
  • Write CFB documents with cfb_writer for forensic inspection or format construction

Quick Start

Read an MSG file and print its subject:

#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';
}

Next Steps

See Also

 English