OabFile Class

An offline address book of Exchange and Outlook in the version 4 Full Details format ([MS-OXOAB] 2.9): the file udetails.oab Outlook keeps in its Offline Address Books folder. It has the schemas of its records, the header record that describes the address list, and a record per Address Book object.

public sealed class OabFile

Example

var book = OabFile.Create();
book.Header.Values[MapiPropertyTag.FromValue(0x6800001F)] = "\\Global Address List";
book.Header.Values[MapiPropertyTag.FromValue(0x68010003)] = 1;
var record = new OabRecord();
record.Values[MapiPropertyTag.FromValue(0x3003001E)] = "/o=Example/ou=Exchange Administrative Group/cn=Recipients/cn=alice";
record.Values[MapiPropertyTag.FromValue(0x39FE001F)] = "alice@example.com";
record.Values[MapiPropertyTag.FromValue(0x3001001F)] = "Alice Martin";
record.Values[MapiPropertyTag.FromValue(0x800F101F)] = new[] { "SMTP:alice@example.com", "smtp:a.martin@example.com" };
record.Values[MapiPropertyTag.FromValue(0x0FFE0003)] = 6;
book.Records.Add(record);
book.Save(path);

var file = OabFile.Load(path);
Assert.Equal("\\Global Address List", file.Name);
var alice = file.Records.Single();
Assert.Equal("alice@example.com", alice.SmtpAddress);
Assert.Equal(["SMTP:alice@example.com", "smtp:a.martin@example.com"], alice.ProxyAddresses);

// A record as a vCard, or as a contact of Outlook
var card = VCard.FromOab(alice);
Assert.Equal("Alice Martin", card.FormattedName);

Constructors

NameDescription
OabFile()

OabFile()

OabFile.cs
public OabFile()

No documentation is available.

Properties

NameDescription
ChecksumGets the checksum of the file, as read (ulSerial): the CRC of the file after its header.
HeaderGets the header record: the name of the address list (0x6800001F), its distinguished name (0x6804001E), its sequence number (0x68010003) and its GUID (0x6802001E).
HeaderPropertiesGets the properties the header record can have (rgHdrAtts).
NameGets the name of the address list (PidTagOfflineAddressBookName).
RecordPropertiesGets the properties the records can have (rgOabAtts), in their order in the records.
RecordsGets the records of the Address Book objects.
SequenceGets the sequence number of the address book (PidTagOfflineAddressBookSequence), which increases with each generation.

Checksum

OabFile.cs

Gets the checksum of the file, as read (ulSerial): the CRC of the file after its header.

public uint Checksum { get; }

Property value

uint

HeaderProperties

OabFile.cs

Gets the properties the header record can have (rgHdrAtts).

public IList<OabPropertyDefinition> HeaderProperties { get; }

Gets the name of the address list (PidTagOfflineAddressBookName).

public string? Name { get; }

Property value

string?

RecordProperties

OabFile.cs

Gets the properties the records can have (rgOabAtts), in their order in the records.

public IList<OabPropertyDefinition> RecordProperties { get; }

Records

OabFile.cs

Gets the records of the Address Book objects.

public IList<OabRecord> Records { get; }

Property value

IList<OabRecord>

Sequence

OabFile.cs

Gets the sequence number of the address book (PidTagOfflineAddressBookSequence), which increases with each generation.

public int? Sequence { get; }

Property value

int?

Methods

NameDescription
Create()Creates an address book with the properties the specification requires in the header record and in the records.
Load(Stream, bool)Reads an address book from a stream, until its end.
Load(ReadOnlySpan<byte>, bool)Reads an address book.
Load(string, bool)Reads an address book, such as udetails.oab.
Save(Stream)Writes the address book, with its checksum. The values of the records must have the types of their properties; the empty strings and binaries are not written, as the specification requires.
Save(string)Writes the address book in a file.
ToByteArray()Returns the content of the file.

Create()

OabFile.cs

Creates an address book with the properties the specification requires in the header record and in the records.

public static OabFile Create()

Returns

OabFile The address book.

Load overloads

Load(Stream, bool)

OabFile.cs

Reads an address book from a stream, until its end.

public static OabFile Load(Stream stream, bool verifyChecksum = true)
Parameters
stream Stream
The stream.
verifyChecksum bool
true to check the checksum of the file.
Returns

OabFile The address book.

Exceptions
InvalidEmailDataException
The file is not an uncompressed version 4 Full Details file, its structures are malformed, or its checksum is invalid.

Load(ReadOnlySpan<byte>, bool)

OabFile.cs

Reads an address book.

public static OabFile Load(ReadOnlySpan<byte> data, bool verifyChecksum = true)
Parameters
data ReadOnlySpan<byte>
The content of the file.
verifyChecksum bool
true to check the checksum of the file.
Returns

OabFile The address book.

Exceptions
InvalidEmailDataException
The file is not an uncompressed version 4 Full Details file, its structures are malformed, or its checksum is invalid.

Load(string, bool)

OabFile.cs

Reads an address book, such as udetails.oab.

public static OabFile Load(string path, bool verifyChecksum = true)
Parameters
path string
The path of the file.
verifyChecksum bool
true to check the checksum of the file.
Returns

OabFile The address book.

Exceptions
InvalidEmailDataException
The file is not an uncompressed version 4 Full Details file, its structures are malformed, or its checksum is invalid.

Save overloads

Save(Stream)

OabFile.cs

Writes the address book, with its checksum. The values of the records must have the types of their properties; the empty strings and binaries are not written, as the specification requires.

public void Save(Stream stream)
Parameters
stream Stream
The stream.
Exceptions
InvalidOperationException
A value does not have the type of its property.

Save(string)

OabFile.cs

Writes the address book in a file.

public void Save(string path)
Parameters
path string
The path of the file.
Exceptions
InvalidOperationException
A value does not have the type of its property.

ToByteArray()

OabFile.cs

Returns the content of the file.

public byte[] ToByteArray()

Returns

byte[] The content.

Exceptions

InvalidOperationException
A value does not have the type of its property.