所以我一直在研究以编程方式为 Outlook 日历创建日历事件。
是否有关于在 .ASPX 页面上显示的 asp.net 网络表单或针对该域的代码示例的任何分步操作。
我尝试按照此示例向日历添加约会,但收到错误“HttpApplicationState 不包含“CreateItem”的定义,并且找不到接受“HttpApplicationState”类型的第一个参数的可访问扩展方法“CreateItem”(是您缺少 using 指令或程序集引用?)
private void AddAppointment()
{
try
{
Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)
Application.CreateItem(Outlook.OlItemType.olAppointmentItem);
newAppointment.Start = DateTime.Now.AddHours(2);
newAppointment.End = DateTime.Now.AddHours(3);
newAppointment.Location = "ConferenceRoom #2345";
newAppointment.Body = "We will discuss progress on the group project.";
newAppointment.AllDayEvent = false;
newAppointment.Subject = "Group Project";
newAppointment.Recipients.Add("Roger Harui");
Outlook.Recipients sentTo = newAppointment.Recipients;
Outlook.Recipient sentInvite = null;
sentInvite = sentTo.Add("Holly Holt");
sentInvite.Type = (int)Outlook.OlMeetingRecipientType.olRequired;
sentInvite = sentTo.Add("David Junca ");
sentInvite.Type = (int)Outlook.OlMeetingRecipientType.olOptional;
sentTo.ResolveAll();
newAppointment.Save();
newAppointment.Display(true);
}
catch (Exception ex)
{
Console.WriteLine("The following error occurred: " + ex.Message);
}
}
这些是我的使用:
using System;
using Outlook = Microsoft.Office.Interop.Outlook;
我是不是完全错了?
编辑#1:我想将 Outlook 日历集成到网站中,以便用户可以将约会添加到他们的 Outlook 日历中。我正在寻找简明的文档来在 ASP.NET webforms 站点上用 C# 实现这一点,并且大多数文档都是针对 Microsoft.Office.Interop 的,这对我来说似乎在本地不起作用。