Contacts, calendar and tasks
editThe items that Outlook types are returned as derived types of MapiMessage, chosen from their message class:
| Message class | Type |
|---|---|
IPM.Contact | MapiContact |
IPM.DistList | MapiDistributionList |
IPM.Appointment | MapiAppointment |
IPM.Schedule.Meeting.Request, .Canceled, .Resp.Pos, .Resp.Tent, .Resp.Neg | MapiMeetingMessage, an appointment: see meeting invitations |
IPM.Task | MapiTask |
IPM.StickyNote | MapiNote |
IPM.Activity | MapiJournal |
any other class, such as IPM.Note or IPM.Post | MapiMessage |
The classes derived from these ones (IPM.Contact.MyForm) get the same types. Every property, typed or not, is available from Properties: see MAPI properties.
Contacts and distribution lists
A MapiContact gives the names, the email addresses, the telephone numbers and the postal addresses of a contact. The Members of a MapiDistributionList are its addresses:
using var file = PstFile.Open(path);
foreach (var item in file.GetFolder("Contacts")!.EnumerateItems())
{
switch (item)
{
case MapiContact contact:
Assert.Equal("contact", contact.GivenName);
Assert.Equal("contact1@rjohnson.id.au", contact.Email1Address);
break;
case MapiDistributionList list:
Assert.Equal("test dist list", list.Name);
Assert.Equal("dist1@rjohnson.id.au", list.Members[1].EmailAddress);
break;
}
}Appointments
A MapiAppointment gives the Start and the End of an appointment, in UTC, its location, its attendees and its reminder. GetRecurrence returns the recurrence of a recurring appointment: its pattern, its end, and the occurrences that are deleted or modified (Exceptions):
using var file = PstFile.Open(path);
var appointment = file.GetFolder("Calendar")!.EnumerateItems().OfType<MapiAppointment>().Single();
Assert.Equal("Test appointment", appointment.Subject);
Assert.Equal(new DateTime(2016, 8, 2, 15, 0, 0, DateTimeKind.Utc), appointment.Start);
// The recurrence: every Tuesday, with deleted and moved occurrences
var recurrence = appointment.GetRecurrence()!;
Assert.Equal(MapiRecurrenceFrequency.Weekly, recurrence.Frequency);
Assert.Equal(MapiDaysOfWeek.Tuesday, recurrence.DaysOfWeek);
Assert.HasCount(3, recurrence.DeletedInstanceDates);
Assert.HasCount(2, recurrence.Exceptions);
Assert.Equal(new DateTime(2016, 8, 23, 9, 0, 0), recurrence.Exceptions[0].StartDateTime);
// The RTF body, decompressed from the compressed RTF property
var rtf = Encoding.ASCII.GetString(appointment.GetRtfBody()!);
Assert.StartsWith(@"{\rtf1", rtf, StringComparison.Ordinal);The dates of a recurrence are in the time zone of the appointment, which TimeZoneDescription describes.
Tasks
A MapiTask gives the Status, the completion, the start and due dates, the owner and the efforts of a task, and GetRecurrence its recurrence.
Sticky notes
A MapiNote is a sticky note (MS-OXONOTE): its text is the Body, its subject is the first line of the text, and it has a Color and the size and position of its window. MapiNoteBuilder writes one, and its Text sets the subject as Outlook does:
using (var writer = PstWriter.Create(stream, leaveOpen: true))
{
var notes = writer.RootFolder.CreateFolder("Notes", "IPF.StickyNote");
notes.AddItem(new MapiNoteBuilder
{
Text = "Call Bob\r\nAbout the quarterly report",
Color = MapiNoteColor.Green,
Width = 200,
Height = 166,
});
}
using var file = PstFile.Open(stream);
var note = Assert.IsType<MapiNote>(file.GetFolder("Notes")!.EnumerateItems().Single());
Assert.Equal("Call Bob", note.Subject);
Assert.Equal("Call Bob\r\nAbout the quarterly report", note.Body);
Assert.Equal(MapiNoteColor.Green, note.Color);
Assert.Equal(200, note.Width);Journal entries
A MapiJournal is a journal entry (MS-OXOJRNL), the record of an activity: its type (a phone call, a meeting, the editing of a document...), its start, end and duration, the companies and contacts it is associated with, and what was done to the document. MapiJournalBuilder writes one, and computes the duration from the start and the end:
var entry = new MapiJournalBuilder
{
Subject = "Call with Bob",
JournalType = "Phone call",
JournalTypeDescription = "Phone call",
Start = new DateTime(2026, 3, 2, 9, 0, 0, DateTimeKind.Utc),
End = new DateTime(2026, 3, 2, 9, 25, 0, DateTimeKind.Utc),
Companies = ["Contoso"],
Contacts = ["Bob Smith"],
};
Assert.Equal(TimeSpan.FromMinutes(25), entry.Duration);
var item = Assert.IsType<MapiJournal>(MsgFile.Load(MsgFile.ToByteArray(entry)));
Assert.Equal("Phone call", item.JournalType);
Assert.Equal(TimeSpan.FromMinutes(25), item.Duration);
Assert.Equal(["Contoso"], item.Companies);