C# 尝试使用C连接Outlook#
我正在尝试使用c#获取Outlook功能(附件、邮件、联系人) 示例代码:C# 尝试使用C连接Outlook#,c#,outlook,registry,office-interop,C#,Outlook,Registry,Office Interop,我正在尝试使用c#获取Outlook功能(附件、邮件、联系人) 示例代码: using System.Text; using Microsoft.Office.Interop.Outlook; namespace Happy_bday_automation { class Program { private void SendEmailtoContact(string name) { string subjectEmail
using System.Text;
using Microsoft.Office.Interop.Outlook;
namespace Happy_bday_automation
{
class Program
{
private void SendEmailtoContact(string name)
{
string subjectEmail = "Happy Bday" + name;
string bodyEmail = "Meeting is one hour later.";
ContactItem contact1 = new ContactItem();
contact1.Email1Address=name+"@ca.com";
this.CreateEmailItem(subjectEmail, contact1.Email1Address, bodyEmail);
}
}
}
因此,当我创建contactItem对象时,我会遇到如下错误
mscorlib.dll中发生类型为“System.Runtime.InteropServices.COMException”的未处理异常
其他信息:检索CLSID为{00061031-0000-0000-C000-0000000000 46}的组件的COM类工厂失败,原因是以下错误:80040154类未注册(HRESULT异常:0x80040154(REGDB_E_CLASSNOTREG))
请提出一些解决方案:)
提前感谢。ContactItem不是可创建的对象,只有Outlook。应用程序是
可以使用
Application.CreateItem(OlimType.olContactItem)
或使用MAPIFolder.Items.Add(“IPM.contact”)
创建新联系人,其中MAPIFolder是联系人文件夹。可以使用Application.Session.GetDefautlFolder(olFolderContacts)
检索默认联系人文件夹。您在注册表中有此记录吗?你可以运行regeditWhy isasp.net
a tag?看看这里:你是否添加了参考:另一个可能的解决方案(当你提供更多信息时,我们将能够更好地提供帮助):