[英]Automate email alert notifications
我能夠編碼出間隔或每日自動發送電子郵件警報,但與 3 個月相比,我似乎無法成功編碼它。
我的情況是,這個自動化電子郵件系統必須檢索並檢查我的數據庫表結束日期,如果今天的日期正好在結束日期前 3 個月,我需要這個系統自動生成一封電子郵件給這個合同客戶提醒他們與我們聯系。
任何建議我該如何編碼? 非常感謝您的幫助 !
已編輯
@v2v2 感謝您建議使用窗口服務。 目前我面臨的另一個問題是我不知道如何更改間隔以檢查提前 3 個月,就像我在上面的場景中描述的那樣。 提前致謝,非常感謝您的幫助!
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key ="Mode" value ="DAILY"/>
<!-- <add key ="Mode" value ="Interval"/>-->
<add key ="IntervalMinutes" value ="1"/>
<add key ="ScheduledTime" value ="19:01:00"/>
</appSettings>
</configuration>
為什么不編寫代碼並使用窗口任務調度/流窗口服務/或在代碼中自行編程。
僅用於例如:
使用系統; 使用 Microsoft.Win32.TaskScheduler;
class Program
{
static void Main(string[] args)
{
// Get the service on the local machine
using (TaskService ts = new TaskService())
{
// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Does something";
// Create a trigger that will fire the task at this time every other day
td.Triggers.Add(new DailyTrigger { DaysInterval = 2 });
// 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);
// Remove the task we just created
ts.RootFolder.DeleteTask("Test");
}
}
}
或者使用Window服務。使用谷歌並嘗試,你可以找到足夠的方法。如果你需要一些幫助,請自己嘗試然后粘貼代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.