Click here to Skip to main content
15,898,770 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All,
I am developing a windows application which has this feature:
When some button is pressed, it will create a outlook task.
This my code in C#:
C#
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;

private void button1_Click(object sender, EventArgs e)
{
    TaskItem OutlookTask = new TaskItem();
    OutlookTask.Actions.Application.CreateItem(OlItemType.olTaskItem);
    OutlookTask.Assign();
    OutlookTask.Recipients.Add("email@domain.ps");
    OutlookTask.Subject = "Testing The Tasks from my application";
    OutlookTask.Body = "Body: Testing The Tasks from my application";
    OutlookTask.DueDate = DateTime.Today;
    OutlookTask.ReminderTime = OutlookTask.DueDate;
    OutlookTask.Save();
}

This is the error I get:
Retrieving the COM class factory for component with CLSID {00061032-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).


Note: I added the reference to use Outlook which is: Microsoft Outlook 14.0 Object Library. I am using VS 2010, and Outlook 2010

Does anybody have an idea what can cause this?

Thanks in advance!
Posted
Updated 4-Jan-11 4:33am
v5
Comments
Manfred Rudolf Bihy 4-Jan-11 10:34am    
Edit: Grammar and spelling, added Outlook and Interop tags, code tags and indentation.

Is MS Office Outlook installed on the machine running the application?
You could also have an issue of 32bit MS Office vs a 64bit machine.

Regards,
Manfred
 
Share this answer
 
One reason is already suggested to you by Manfred, other could be if Microsoft Outlook is not properly installed and configured on the system. Basically you should be able to run Outlook outside of your application too.

Support links: Link 1[^]
Link 2[^]
 
Share this answer
 
Good morning,
Outlook is installed on the running machine.
My machine is 64bit.
I've changed the CPU into X86 in VS 2010, but the problem still appear.
The error is fired exactly in the following line:

TaskItem OutlookTask = new TaskItem();

and thank you for your replies.

Regards
 
Share this answer
 
Comments
[no name] 5-Jan-11 8:59am    
Don't add an answer. You should modify your original question to provide additional information
You can't create a Task using new

TaskItem OutlookTask = (TaskItem)Application.CreateItem(OlItemType.olTaskItem);


or

TaskItem OutlookTask = tasks.Items.add(OlItemType.olTaskItem);
 
Share this answer
 
Comments
obarahmeh 5-Jan-11 8:40am    
There is an error for your sentences:
TaskItem OutlookTask = (TaskItem)Application.CreateItem(OlItemType.olTaskItem);
Application is an ambiguous between Outlook.Application and Window.forms.Application .

and the second sentence:
TaskItem OutlookTask = tasks.Items.add(OlItemType.olTaskItem);
shows an error in tasks which does not exist in this context

Is there any missing, any references??

I've referenced the following:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;
[no name] 5-Jan-11 8:58am    
You need to do some work on your own. The code was an example and MUST be configured appropriately for YOUR application.

If you want code written for you then contact me to discuss rates.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900