Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Outlook Interop
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#:
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 4-Jan-11 5:25am
Edited 4-Jan-11 5:33am
v5
Comments
Manfred R. Bihy at 4-Jan-11 10:34am
   
Edit: Grammar and spelling, added Outlook and Interop tags, code tags and indentation.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  
Comments
Mark Nischalke at 5-Jan-11 8:59am
   
Don't add an answer. You should modify your original question to provide additional information
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

You can't create a Task using new
 
TaskItem OutlookTask = (TaskItem)Application.CreateItem(OlItemType.olTaskItem);
 
or
 
TaskItem OutlookTask = tasks.Items.add(OlItemType.olTaskItem);
  Permalink  
Comments
Mark Nischalke at 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.
obarahmeh at 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;

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

  Print Answers RSS
0 OriginalGriff 406
1 /\jmot 180
2 Suraj Sahoo | Coding Passion 170
3 Afzaal Ahmad Zeeshan 159
4 BillWoodruff 154
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 5 Jan 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100