35 releases (14 breaking)

0.15.3 Oct 24, 2024
0.14.5 Aug 1, 2024
0.14.4 Jul 23, 2024
0.13.0 Mar 21, 2024

#51 in Windows APIs

Download history 142/week @ 2024-07-24 148/week @ 2024-07-31 5/week @ 2024-08-07 1/week @ 2024-08-14 138/week @ 2024-09-04 44/week @ 2024-09-11 222/week @ 2024-09-18 184/week @ 2024-09-25 17/week @ 2024-10-02 8/week @ 2024-10-09 1/week @ 2024-10-16 126/week @ 2024-10-23 5/week @ 2024-10-30 3/week @ 2024-11-06

135 downloads per month

MIT license

2.5MB
48K SLoC

outlook-mapi

This crate implements Rust bindings for the Outlook MAPI COM APIs. The bindings are generated by the Windows crate in outlook-mapi-sys.

Getting Started

Include a reference to the latest version of outlook-mapi in your Cargo.toml.

See the docs for more details.

Safety

Most of the bindings are re-exported transparently from outlook-mapi-sys as the outlook-mapi::sys module, and they are still marked unsafe. Unlike typical idiomatic Rust crates wrapped around a -sys crate, the emphasis of this crate is on writing as little manual wrapper code as possible. This way, outlook-mapi can project 100% of the Outlook MAPI COM API, but the downside is you will need to wrap most uses in an unsafe block or function.

Convenience Types

This crate does add several Rust structs and macro definitions to make it easier to work with MAPI types, and to add some lifetime guarantees when used in place of the raw MAPI API. For instance, the typical sequence of MAPI calls in C++ looks something like this:

MAPIInitialize(...);

// Logon with a new session.
MAPILogonEx(..., &session);

// Do stuff with the session...

// This should be the last reference to the session!
session->Release();

MAPIUninitialize();

The convenience types ensure that you have a matching pair of MAPIInitialize and MAPIUninitialize calls, and they live at least as long as the session is in use. They also constrain which flags you can pass to each of these calls:

println!("Initializing MAPI...");
let initialized = Initialize::new(Default::default()).expect("failed to initialize MAPI");
println!("Trying to logon to the default profile...");
let logon = Logon::new(
    initialized,
    Default::default(),
    None,
    None,
    LogonFlags {
        extended: true,
        unicode: true,
        logon_ui: true,
        use_default: true,
        ..Default::default()
    },
)
.expect("should be able to logon to the default MAPI profile");
println!("Success!");

Dependencies

~127MB
~2M SLoC