定期タスクを作成する
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);