2015-06-24 49 views
-2

我能夠編寫出間隔或每日自動化電子郵件警報發送,但我似乎無法成功編碼它比較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> 

回答

0

爲什麼不寫代碼並使用窗口任務schedular/ow窗口服務/或編程它本身的代碼。

僅用於例如:

使用系統; using 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 service.Use谷歌和嘗試,你可以找到足夠的Method.Please自己嘗試,然後粘貼代碼,如果你需要了解它的一些幫助。

+0

有關如何更改上面的應用配置的任何想法?@ v2v2 –