在C#中创建Outlook任务时出错 [英] Error creating Outlook Task in C#

查看:122
本文介绍了在C#中创建Outlook任务时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我正在开发具有以下功能的Windows应用程序:
按下某个按钮时,将创建一个Outlook任务.
这是我在C#中的代码:

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)).



注意:我添加了使用Outlook的引用,即Microsoft Outlook 14.0对象库.我正在使用VS 2010和Outlook 2010

有人知道会导致这种情况的原因吗?



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!

推荐答案

运行该应用程序的计算机上是否已安装MS Office Outlook?
您可能还会遇到32位MS Office与64位计算机的问题.

问候,
Manfred
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


Manfred已经向您建议了一个原因,另一个原因是系统上未正确安装和配置Microsoft Outlook.基本上,您也应该能够在应用程序之外运行Outlook.

支持链接:链接1 [ ^ ]
链接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[^]


早上好,
Outlook已安装在运行的计算机上.
我的机器是64位的.
我已在VS 2010中将CPU更改为X86,但问题仍然出现.
该错误正好在以下行中触发:

TaskItem OutlookTask = new TaskItem();

并感谢您的答复.

问候
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


这篇关于在C#中创建Outlook任务时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆