outlook with windows service
本文关键字:service windows with outlook | 更新日期: 2023-09-27 18:09:25
为了访问outlook日历,我创建了一个windows服务。
public SOutlook()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("MyLogSrc"))
{
System.Diagnostics.EventLog.CreateEventSource("MyLogSrc", "MyLog");
}
//set our event log to system created log
myEventLog.Source = "MyLogSrc";
myEventLog.Log = "MyLog";
tmrDelay = new System.Timers.Timer(5000);
tmrDelay.Elapsed += new System.Timers.ElapsedEventHandler(tmrDelay_Elapsed);
}
void tmrDelay_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
GetAllCalendarItems();
}
GatAllCalenderItems()是一个访问outlook日历,获取所需信息,然后将所有信息保存在数据库中的函数。我已经测试过了,它工作得很好(计时器也工作)。由于某些原因,此函数在windows服务中不起作用。
protected override void OnStart(string[] args)
{
myEventLog.WriteEntry("MyService started");
tmrDelay.Enabled = true;
}
有人能帮我一下吗
到底什么不行?Outlook(或任何其他Office应用)不能在服务中使用