Create, Save and Read Outlook Tasks

Create Outlook Tasks

Aspose.Email for .NET allows you to create Outlook tasks and save them to MSG format. The MapiTask class provides a number of properties such as PercentComplete, EstimatedEffort, ActualEffort, History, LastUpdate, and others, to accommodate and set information required for an Outlook task. This article shows how to create, save and read a MapiTask from disk. To create and save a task to disk:

  1. Instantiate a new object of the MapiContact class.
  2. Enter task property information.
  3. Save the task to disc in MSG format.

The following code snippet shows you how to create, save and read Tasks.

Read MAPI Tasks

The MapiContact class object is used to cast the MapiMessage object that loads a task from the disk as MSG format. The following code snippet shows you how to read a MapiTask.

Read VToDo Tasks

Google Tasks exported in iCalendar format as VToDo events can be loaded using the MapiTask class as shown in the following code sample. The following code snippet shows you how to read a VToDo Task.

Add Reminder Information to MAPI Tasks

Similar to Microsoft Outlook, Aspose.Email can add reminder information to a MapiTask. The following code snippet shows you how to add reminder information to a MapiTask.

Add Attachments to MAPI Tasks

The following code snippet shows you how to add attachments to a MapiTask.

Add Recurrence to MAPI Tasks

Aspose.Email allows creating a recurring task where the recurrence can be daily, weekly, monthly, or yearly. The following code snippet shows you how to create a task with different recurrence types.

Convert Tasks to MHT

Aspose.Email can generate MailMessage like output during the conversion of a MapiTask to MHT.

MSG to HTML Convertion Preserving Task Fields

The HtmlFormatOptions.RenderTaskFields enumeration allows you to specify that task fields should be included in the header of the saved HTML file. The following code snippet shows how to preserve task fields in a header when saving a html file:

var msg = MapiMessage.Load("task.msg");
HtmlSaveOptions opt = SaveOptions.DefaultHtml;
opt.HtmlFormatOptions = HtmlFormatOptions.WriteHeader | HtmlFormatOptions.RenderTaskFields;
msg.Save("task.html", opt);