如何使用C#Task Scheduler托管包装发送电子邮件

使用以下代码示例,我创建了一个任务:

using (TaskService ts = new TaskService())
      {
         // Create a new task definition and assign properties
         TaskDefinition td = ts.NewTask();
         td.RegistrationInfo.Description = "Does something";

         // Add a trigger that, starting tomorrow, will fire every other week on Monday
         // and Saturday and repeat every 10 minutes for the following 11 hours
         WeeklyTrigger wt = new WeeklyTrigger();
         wt.StartBoundary = DateTime.Today.AddDays(1);
         wt.DaysOfWeek = DaysOfTheWeek.Monday | DaysOfTheWeek.Saturday;
         wt.WeeksInterval = 2;
         wt.Repetition.Duration = TimeSpan.FromHours(11);
         wt.Repetition.Interval = TimeSpan.FromMinutes(10);
         td.Triggers.Add(wt)

         // Create an action that will launch Notepad whenever the trigger fires
         td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null));

         // Register the task in the root folder
         ts.RootFolder.RegisterTaskDefinition("Test", td);
      }
   }

但是,如何为我创建的任务以编程方式添加Windows Task Scheduler中显示的以下“发送电子邮件”操作: 在此处输入图片说明

笑312

您正在寻找的是EmailAction

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章