S
sokolo
Hello,
I wrote a windows service application however it is not working. The
service is supposed to enter a new task every 5 sec within Microsoft
Outlook.
Here is the code for application:
public partial class CheckAccountsService : ServiceBase
{
private Timer timer = null;
public CheckAccountsService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
EventLog.WriteEntry("It is starting!!!!", "It is
starting!!");
System.Threading.Thread.Sleep(10000);
//Debug.Write("x");
// TODO: Add code here to start your service
timer.Enabled = true;
timer.Start();
createTestTask();
}
protected override void OnStop()
{}
public enum Importance
{
High = 0,
Normal = 1,
Low = 2
}
public static void createTestTask()
{
CreateOutlookTask("bla bla ", DateTime.Parse("6/6/2006 1:00
PM"), Importance.High, "bla bla");
}
public static void CreateOutlookTask(string Body, DateTime
dueDate, Importance Importance, string Subject)
{
// Create an Outlook Application object.
Application outLookApp = new Application();
// Create a new TaskItem.
TaskItem newTask =
(TaskItem)outLookApp.CreateItem(OlItemType.olTaskItem);
// Configure the task at hand and save it.
newTask.Body = Body;
newTask.DueDate = dueDate;
switch (Importance)
{
case Importance.High:
newTask.Importance = OlImportance.olImportanceHigh;
break;
case Importance.Normal:
newTask.Importance =
OlImportance.olImportanceNormal;
break;
case Importance.Low:
newTask.Importance = OlImportance.olImportanceLow;
break;
}
newTask.ReminderSet = true;
newTask.ReminderTime = dueDate;
newTask.Subject = Subject;
newTask.Save();
}
private void ServiceTimer_Tick(object sender,
System.Timers.ElapsedEventArgs e)
{
this.timer.Stop();
createTestTask();
this.timer.Start();
}
}
I get the following errors :
********
Rejected Safe Mode action : Microsoft Office Outlook.
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
********
AND
********
Service cannot be started. System.Runtime.InteropServices.COMException
(0x80080005): Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following
error: 80080005.
at AccountRemainder.CheckAccountsService.CreateOutlookTask(String
Body, DateTime dueDate, Importance Importance, String Subject) in
C:\Documents and Settings\psokolowski\My Documents\Visual Studio
2005\Projects\AccountRemainder\WindowsService1\CheckAccountsService.cs:line
70
at AccountRemainder.CheckAccountsService.createTestTask() in
C:\Documents and Settings\psokolowski\My Documents\Visual Studio
2005\Projects\AccountRemainder\WindowsService1\CheckAccountsService.cs:line
55
at AccountRemainder.CheckAccountsService.OnStart(String[] args) in
C:\Documents and Settings\psokolowski\My Documents\Visual Studio
2005\Projects\AccountRemainder\WindowsService1\CheckAccountsService.cs:line
32
at
System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object
state)
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
********
Any idea ?
I wrote a windows service application however it is not working. The
service is supposed to enter a new task every 5 sec within Microsoft
Outlook.
Here is the code for application:
public partial class CheckAccountsService : ServiceBase
{
private Timer timer = null;
public CheckAccountsService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
EventLog.WriteEntry("It is starting!!!!", "It is
starting!!");
System.Threading.Thread.Sleep(10000);
//Debug.Write("x");
// TODO: Add code here to start your service
timer.Enabled = true;
timer.Start();
createTestTask();
}
protected override void OnStop()
{}
public enum Importance
{
High = 0,
Normal = 1,
Low = 2
}
public static void createTestTask()
{
CreateOutlookTask("bla bla ", DateTime.Parse("6/6/2006 1:00
PM"), Importance.High, "bla bla");
}
public static void CreateOutlookTask(string Body, DateTime
dueDate, Importance Importance, string Subject)
{
// Create an Outlook Application object.
Application outLookApp = new Application();
// Create a new TaskItem.
TaskItem newTask =
(TaskItem)outLookApp.CreateItem(OlItemType.olTaskItem);
// Configure the task at hand and save it.
newTask.Body = Body;
newTask.DueDate = dueDate;
switch (Importance)
{
case Importance.High:
newTask.Importance = OlImportance.olImportanceHigh;
break;
case Importance.Normal:
newTask.Importance =
OlImportance.olImportanceNormal;
break;
case Importance.Low:
newTask.Importance = OlImportance.olImportanceLow;
break;
}
newTask.ReminderSet = true;
newTask.ReminderTime = dueDate;
newTask.Subject = Subject;
newTask.Save();
}
private void ServiceTimer_Tick(object sender,
System.Timers.ElapsedEventArgs e)
{
this.timer.Stop();
createTestTask();
this.timer.Start();
}
}
I get the following errors :
********
Rejected Safe Mode action : Microsoft Office Outlook.
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
********
AND
********
Service cannot be started. System.Runtime.InteropServices.COMException
(0x80080005): Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following
error: 80080005.
at AccountRemainder.CheckAccountsService.CreateOutlookTask(String
Body, DateTime dueDate, Importance Importance, String Subject) in
C:\Documents and Settings\psokolowski\My Documents\Visual Studio
2005\Projects\AccountRemainder\WindowsService1\CheckAccountsService.cs:line
70
at AccountRemainder.CheckAccountsService.createTestTask() in
C:\Documents and Settings\psokolowski\My Documents\Visual Studio
2005\Projects\AccountRemainder\WindowsService1\CheckAccountsService.cs:line
55
at AccountRemainder.CheckAccountsService.OnStart(String[] args) in
C:\Documents and Settings\psokolowski\My Documents\Visual Studio
2005\Projects\AccountRemainder\WindowsService1\CheckAccountsService.cs:line
32
at
System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object
state)
For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
********
Any idea ?