C# 如何在2010 AddIn项目中以编程方式关闭outlook outlook?
我需要在每天00:00关闭outlook。是否有任何方法可以通过编程方式关闭outlook 谢谢你的帮助。尽情享受吧C# 如何在2010 AddIn项目中以编程方式关闭outlook outlook?,c#,outlook-addin,shutdown,C#,Outlook Addin,Shutdown,我需要在每天00:00关闭outlook。是否有任何方法可以通过编程方式关闭outlook 谢谢你的帮助。尽情享受吧 Outlook.Application OutlookApp; OutlookApp = (Outlook.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application"); OutlookApp.Quit() public partial class ThisAd
Outlook.Application OutlookApp;
OutlookApp = (Outlook.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application");
OutlookApp.Quit()
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Thread thread = new Thread(p =>
{
DateTime now = DateTime.Now;
DateTime endOfDay = DateTime.Today.AddDays(1);
TimeSpan timeLeftForClose = endOfDay.Subtract(now);
Thread.Sleep(timeLeftForClose);
this.Application.Quit();
});
thread.Start();
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
}
享受吧
这对我有用!特别感谢您的计时器操作。祝您度过愉快的一天!这对我有用!特别感谢您的计时器操作。祝您度过愉快的一天!