无法从IIS运行Outlook库 [英] Failed to run Outlook libraries from IIS

查看:157
本文介绍了无法从IIS运行Outlook库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一点我不知道要解决的问题。
我正在使用C#,Visual Studio 2010和我使用Outlook库的错误页面。
在我的项目中,我添加了以下库:Microsoft.Office.Interop.Outlook
如果我使用Visual Studio提供给我的服务器运行网站,页面工作正常。
如果我通过IIS运行页面,日志记录显示我:
由于以下错误,无法检索具有CLSID {0006F03A-0000-0000-C000-000000000046}的组件的COM类工厂:80070005访问被拒绝。(HRESULT异常:0x80070005(E_ACCESSDENIED))。

I have a little problem that I don't know to solve. I'm working with C#, Visual Studio 2010 and the error page that I have I am using Outlook libraries. In my project I added the following library: "Microsoft.Office.Interop.Outlook" If I run the website using the server that Visual Studio gives me, the page works perfectly. If I run the page through IIS, logging says me: "Could not retrieve the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))."

有谁知道为什么会这样?
我该怎么办才能修复它?

Does anyone know why that is? What should I do to fix it?

我想用c#创建一个outlook预约,保存这个在我的一个服务器文件夹中预约然后通过电子邮件发送它,我该怎么办?

I want to create an outlook appointment using c#, save this appointment in one of my server folders and then send it attached in an email, how can I do it?

我的代码是这样的:

using Microsoft.Office.Interop;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Net.Mail;
Outlook.Application outlookApp = (Outlook.Application)new Outlook.Application();
Outlook.AppointmentItem appointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
appointment.Subject = subject;
appointment.Body = comments;
appointment.Location = location;
appointment.StartUTC = dateInit;
appointment.EndUTC = dateEnd;
appointment.ReminderSet = true;
appointment.ReminderMinutesBeforeStart = advideInMinutes;
appointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
string appointmentPath = "c:\\webroot\\appointment\\appointmentName.msg";
appointment.SaveAs(appointmentPath);
MailMessage mail = new MailMessage();
mail.To.Add(new System.Net.Mail.MailAddress("mail@domain.com"));
mail.From = new System.Net.Mail.MailAddress("mail@domain.com", "MyName", System.Text.Encoding.UTF8);
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.Normal;
Attachment appointmentAttahment = new Attachment(appointmentPath);
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("authsmtp.mydomain.com");
smtp.Credentials = new System.Net.NetworkCredential(Settings.Items["mail@domain.com", "password");
smtp.EnableSsl = false;
smtp.Send(mail);
appointmentAttahment.Dispose();


推荐答案

看起来你正试图从IIS自动化Outlook应用。为此,您需要在IIS服务器上安装Outlook。即使您可以使用它,也不是支持的方案。

Looks like you are trying to automate Outlook from an IIS application. For that to work, you would need to install Outlook on your IIS server. Even if you would get that working, it is not a supported scenario.

http://support.microsoft.com/kb/257757

Microsoft目前不推荐,也不支持,从任何无人参与的非交互式客户端应用程序或组件(包括ASP,ASP.NET,DCOM和NT服务)自动化Microsoft Office应用程序,因为Office在此环境中运行时可能会出现不稳定的行为和/或死锁。

"Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment."

如果您使用的是Exchange服务器,则可以使用 Exchange Web Services(EWS)

Provided that you are using Exchange server you could use the Exchange Web Services (EWS)

以下是如何创建的一个示例使用EWS预约:
http: //msdn.microsoft.com/en-us/library/exchange/dd633661(v= exchg.80).aspx

Here is one example of how to create appointments using EWS: http://msdn.microsoft.com/en-us/library/exchange/dd633661(v=exchg.80).aspx

这篇关于无法从IIS运行Outlook库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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