无法创建Outlook日历事件
问题描述:
我想在outlook calendar.i中创建事件.POC .IT工作正常。当它在我的项目中使用时,它不工作。我无法创建日历活动。任何帮助表示赞赏无法创建Outlook日历事件
_Application olApp = (_Application)new Application();
'NameSpace mapiNS = olApp.GetNamespace("MAPI");
string profile = "";
mapiNS.Logon(profile, null, null, null);
_AppointmentItem apt = (_AppointmentItem)
olApp.CreateItem(OlItemType.olAppointmentItem);
// set some properties
apt.Subject = "Test";
apt.Body = "Testing body";
apt.Start = new DateTime(2017, 5, 20, 13, 30, 00);
apt.End = new DateTime(2017, 5, 20, 14, 30, 00);
apt.ReminderMinutesBeforeStart = 15; // One week
apt.BusyStatus = OlBusyStatus.olTentative; // Makes it appear bold in the calendar - which I like!
apt.AllDayEvent = false;
apt.Location = "Hyderabad";
bool res=apt.ForceUpdateToAllAttendees;
apt.Save();
//当我使用项目
_public bool CreateOutlookCalendarEvent(EventContent objEvent) {
try
{
Application olApp = (_Application)new Application();
NameSpace mapiNS = olApp.GetNamespace("MAPI");
string profile = "";
mapiNS.Logon(profile, null, null, null);
_AppointmentItem apt = (_AppointmentItem)
olApp.CreateItem(OlItemType.olAppointmentItem);
// set some properties
apt.Subject = objEvent.EventName;
apt.Body = objEvent.EventDescription;
apt.Start = objEvent.EventStartDate;
apt.End = objEvent.EventEndDate;
apt.ReminderMinutesBeforeStart = 15; // One week
apt.BusyStatus = OlBusyStatus.olTentative; // Makes it appear bold in the calendar - which I like!
apt.AllDayEvent = false;
apt.Location = objEvent.EventAddress;
bool res = apt.ForceUpdateToAllAttendees;
apt.Save();
objEvent.EntryID = Convert.ToInt32(apt.EntryID);
// Prepare the parameters
string customTableClassName = "customtable.OutlookCalendar";
// Check if Custom table 'Sample table' exists
DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
if (customTable != null)
{
// Create new custom table item
CustomTableItem newCustomTableItem = CustomTableItem.New(customTableClassName);
// Set the ItemText field value
newCustomTableItem.SetValue("EventID", objEvent.EventID);
newCustomTableItem.SetValue("EventName", objEvent.EventName);
newCustomTableItem.SetValue("EventDescription", objEvent.EventDescription);
newCustomTableItem.SetValue("EventStartDate", objEvent.EventStartDate);
newCustomTableItem.SetValue("EventEndDate", objEvent.EventEndDate);
newCustomTableItem.SetValue("EventAddress", objEvent.EventAddress);
newCustomTableItem.SetValue("Recivier", objEvent.Recivier);
newCustomTableItem.SetValue("EntryID", "New text");
// Insert the custom table item into database
newCustomTableItem.Insert();
return true;
}
return false;
}
答
如果你想要做这个快捷方式,检查出我的WebPart到API转换器,在里面,它有说明关于如何创建Outlook事件提要,以便他们可以将事件保存到Outlook中。它包含所有转换和支持代码(只要确保在导入时包含代码文件和全局文件夹)。
https://devnet.kentico.com/marketplace/web-parts/webpart-to-api-converter
它被用来在页面上是这样的: http://www.ecasd.us/District/About/Events/2016-2017-School-Year-Calendar/Board-of-Education-Meeting-(16)
- 点击“订阅这个搜索与您的个人日历”
- 点击弹出底部的“下载iCal档案” up
你能解释一下不起作用吗?插入到新的自定义表项不起作用?或试图找出如何将自定义表项转换为outlook可以使用的日历事件文件? –