Eli*_*seo 3 .net c# outlook iis-7.5 windows-server-2012-r2
我需要使用 创建 Outlook 约会microsoft.office.interop.outlook
,但是,虽然我可以让它在我自己的工作站上本地工作,并且如果我通过服务器的浏览器运行 Web 应用程序,它也可以工作,但当我从外部连接到服务器时,它就不起作用。
因此,我认为这可能是一个许可问题。
我将其更改application pool identity
为“ LocalSystem
”,所以现在我没有收到拒绝访问错误。不幸的是,它实际上不起作用。
应用程序的行为就像已成功创建约会一样,但约会不会出现在 Outlook 中。
这是我的 aspx.cs 页面顶部的包含文件
using Outlook = Microsoft.Office.Interop.Outlook;
Run Code Online (Sandbox Code Playgroud)
这是我用来弹出约会的代码。
Outlook.Application apptApp = new Outlook.Application();
Outlook.AppointmentItem appt =
apptApp.CreateItem(Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem;
appt.Subject = txtFirstName.Text + " " + txtLastName.Text;
appt.Body = txtComment.Text;
appt.AllDayEvent = false;
appt.Start = DateTime.Parse(txtReminderDate.Text + " 8:00 AM");
appt.End = DateTime.Parse(txtReminderDate.Text + " 9:00 AM");
appt.Display(false);
Run Code Online (Sandbox Code Playgroud)
正如我所说,如果我localhost
在服务器上使用它就可以工作,但是如果我尝试通过另一台机器从外部访问该应用程序,它什么也不做。
我确实Outlook 2003
在服务器上安装了以访问 interop.outlook 文件并添加了对 microsoft.office.core
.
任何帮助将不胜感激,谢谢!
在 web.config 文件中设置授权访问:
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
Run Code Online (Sandbox Code Playgroud)
如果有帮助,我使用以下方法来创建 Outlook 约会:
private void CreateOutlookGroupMeetingAppointment(List<string> emailRecipients, string meetingPlace, string shortDescription, string longDescription, DateTime start, DateTime finish)
{
try
{
Microsoft.Office.Interop.Outlook.Application ApplicationInstance = null;
Microsoft.Office.Interop.Outlook.AppointmentItem AppointmentInstance = null;
ApplicationInstance = new Microsoft.Office.Interop.Outlook.Application();
AppointmentInstance = (Microsoft.Office.Interop.Outlook.AppointmentItem) ApplicationInstance.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
foreach (string EmailRecipient in emailRecipients)
{
AppointmentInstance.Recipients.Add(EmailRecipient);
}
AppointmentInstance.Subject = shortDescription;
AppointmentInstance.Body = longDescription;
AppointmentInstance.Location = meetingPlace;
AppointmentInstance.Start = start;
AppointmentInstance.End = finish;
AppointmentInstance.ReminderSet = true;
AppointmentInstance.ReminderMinutesBeforeStart = 15;
AppointmentInstance.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
AppointmentInstance.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
AppointmentInstance.Save();
AppointmentInstance.Send();
}
catch //(Exception ex)
{
//ex.HandleException();
}
}
Run Code Online (Sandbox Code Playgroud)
我使用 .Net 4.5,并引用名为“Microsoft.Office.Interop.Outlook”的扩展(项目 => 添加引用)(版本 15.0.0.0,文件版本 15.0.4420.1017)