创建循环任务
Contents
[
Hide
]
VSTO
下面的代码片段展示了基于日期的任务循环:
Outlook.TaskItem task = Application.CreateItem(
Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
task.Subject = "Tax Preparation";
task.StartDate = DateTime.Parse("4/1/2007 8:00 AM");
task.DueDate = DateTime.Parse("4/15/2007 8:00 AM");
Outlook.RecurrencePattern pattern = task.GetRecurrencePattern();
pattern.RecurrenceType = Outlook.OlRecurrenceType.olRecursYearly;
pattern.PatternStartDate = DateTime.Parse("4/1/2007");
pattern.NoEndDate = true;
task.ReminderSet = true;
task.ReminderTime = DateTime.Parse("4/1/2007 8:00 AM");
task.Save();
Aspose.Email
Aspose.Email for .NET 允许您创建 Outlook 任务并保存为 MSG 格式。 MapiTask 该类提供了多个属性,如 Percentcomplete、Estimatedeffort、ActualEffort、History、LastUpdate 等,用于设置 Outlook 任务所需的信息。本文展示了如何在磁盘上创建、保存和读取 MapiTask。
Aspose.Email 允许创建循环任务,循环周期可以是每日、每周、每月或每年。以下代码示例说明了如何创建每周循环的任务。
DateTime startDate = new DateTime(2015, 04, 30, 10, 00, 00);
MapiTask task = new MapiTask("abc", "def", startDate, startDate.AddHours(1));
task.State = MapiTaskState.NotAssigned;
// Set the weekly recurrence
var rec = new MapiCalendarDailyRecurrencePattern
{
PatternType = MapiCalendarRecurrencePatternType.Day,
Period = 1,
WeekStartDay = DayOfWeek.Sunday,
EndType = MapiCalendarRecurrenceEndType.NeverEnd,
OccurrenceCount = 0,
};
task.Recurrence = rec;
task.Save("AsposeDaily.msg", TaskSaveFormat.Msg);