如何添加使用互操作的新的会议要求Outlook日历? [英] How do I add a new meeting request to an Outlook calendar using interop?
问题描述
好吧,我试图连接到使用互操作在C#中共享Outlook日历,并添加一个新的会议请求。
下面就是我这么远,我using语句开始(这是Windows窗体):
使用系统;
使用System.Collections.Generic;
使用System.ComponentModel;
使用的System.Reflection;使用System.Windows.Forms的
;使用Outlook = Microsoft.Office.Interop.Outlook
;
然后,我有所谓的约会一个公共类,这是如下:
公共类预约
{
公共字符串ConversationTopic {搞定;组; }
公众诠释持续时间{搞定;组; }
公共DateTime的开始时间{搞定;组; }
公共DateTime的结束时间{搞定;组; }
公共字符串组织者{搞定;组; }
公众诠释ReminderMinutesBeforeStart {搞定;组; }
公共字符串RequiredAttendees {搞定;组; }
公共字符串主题{搞定;组; }
公共字符串车身{搞定;组; }
}
我有一个新的空白窗口与数据网格视图目前所谓dataGridView1形成。窗体加载事件代码如下:
私人无效Form1_Load的(对象发件人,EventArgs五)
{
Outlook.Application oApp;
oApp =新Outlook.Application();
Outlook.NameSpace ONS = oApp.GetNamespace(MAPI);
oNS.Logon(Missing.Value,Missing.Value,真实,真实);
Outlook.Recipient oRecip =(Outlook.Recipient)oNS.CreateRecipient(富巴);
Outlook.MAPIFolder oFolder =(Outlook.MAPIFolder)oNS.GetSharedDefaultFolder(oRecip,Outlook.OlDefaultFolders.olFolderCalendar);
名单,LT;任命> appointmentList =新的List<任命>();
的foreach(在oFolder.Items对象的项目)
{
Outlook.AppointmentItem thisOne =(Outlook.AppointmentItem)项目;
appointmentList.Add(新任命{ConversationTopic = thisOne.ConversationTopic,持续时间= thisOne.Duration,结束时间= thisOne.End,主办单位= thisOne.Organizer,ReminderMinutesBeforeStart = thisOne.ReminderMinutesBeforeStart,RequiredAttendees = thisOne.RequiredAttendees,开始时间= thisOne 。开始,主题= thisOne.Subject,身体= thisOne.Body});
}
dataGridView1.AutoGenerateColumns = TRUE;
dataGridView1.DataSource = appointmentList;
dataGridView1.Sort(dataGridView1.Columns [主题],ListSortDirection.Descending);
}
这完美的作品在连接到我的日历和填充我的数据网格视图与所有我的有关日历信息。现在我想以编程方式发送一个新的会议请求到日历
我猜会议请求是oFolder.Item所以我觉得我要键入:
oFolder.Items.Add(*详情请点击这里*);
括号内,智能感知只是说以下内容:
dynamic_Items.Add([对象类型= Type.Missing])
块引用>
现在我米难倒和帮助,将不胜感激。
感谢
解决方案使用Outlook = Microsoft.Office.Interop.Outlook;
私人无效SetRecipientTypeForAppt()
{
Outlook.AppointmentItem聘任=
Application.CreateItem(
Outlook.OlItemType.olAppointmentItem)
作为Outlook.AppointmentItem;
appt.Subject =客户评价;
appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
appt.Location =二千〇二十一分之三十六;
appt.Start = DateTime.Parse(2006/10/20上午10点00分);
appt.End = DateTime.Parse(2006/10/20 11:00 AM);
Outlook.Recipient recipRequired =
appt.Recipients.Add(瑞安格雷格);
recipRequired.Type =
(INT)Outlook.OlMeetingRecipientType.olRequired;
Outlook.Recipient recipOptional =
appt.Recipients.Add(彼得Allenspach);
recipOptional.Type =
(INT)Outlook.OlMeetingRecipientType.olOptional;
Outlook.Recipient recipConf =
appt.Recipients.Add(CONF房二千零二十一分之三十六(14)AV);
recipConf.Type =
(INT)Outlook.OlMeetingRecipientType.olResource;
appt.Recipients.ResolveAll();
appt.Display(假);
}
通过如何:的创建会议请求,添加收件人,并指定一个位置
Ok, I am trying to connect to a shared Outlook Calendar in C# using Interop and add a new meeting request.
Here's what I've got so far, starting with my using statements (this is a Windows form):
using System; using System.Collections.Generic; using System.ComponentModel; using System.Reflection; using System.Windows.Forms; using Outlook = Microsoft.Office.Interop.Outlook;
Then I have a public class called "Appointments" which is below:
public class Appointments { public string ConversationTopic { get; set; } public int Duration { get; set; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } public string Organizer { get; set; } public int ReminderMinutesBeforeStart { get; set; } public string RequiredAttendees { get; set; } public string Subject { get; set; } public string Body { get; set; } }
I have a new blank windows form with a Data Grid View currently called dataGridView1. The form load event code is below:
private void Form1_Load(object sender, EventArgs e) { Outlook.Application oApp; oApp = new Outlook.Application(); Outlook.NameSpace oNS = oApp.GetNamespace("mapi"); oNS.Logon(Missing.Value, Missing.Value, true, true); Outlook.Recipient oRecip = (Outlook.Recipient)oNS.CreateRecipient("Foo bar"); Outlook.MAPIFolder oFolder = (Outlook.MAPIFolder) oNS.GetSharedDefaultFolder(oRecip, Outlook.OlDefaultFolders.olFolderCalendar); List<Appointments> appointmentList = new List<Appointments>(); foreach (object item in oFolder.Items) { Outlook.AppointmentItem thisOne = (Outlook.AppointmentItem)item; appointmentList.Add(new Appointments { ConversationTopic = thisOne.ConversationTopic, Duration = thisOne.Duration, EndTime = thisOne.End, Organizer = thisOne.Organizer, ReminderMinutesBeforeStart = thisOne.ReminderMinutesBeforeStart, RequiredAttendees = thisOne.RequiredAttendees, StartTime = thisOne.Start, Subject = thisOne.Subject, Body = thisOne.Body }); } dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = appointmentList; dataGridView1.Sort(dataGridView1.Columns["Subject"], ListSortDirection.Descending); }
This works flawlessly in connecting to my calendar and filling my Data Grid View with all of my relevant calendar information. Now I want to programmatically send a new Meeting Request to the calendar.
I'm guessing a Meeting Request is an oFolder.Item so I think I want to type:
oFolder.Items.Add(* details here *);
Inside the brackets, intellisense simply says the following:
dynamic_Items.Add([object Type = Type.Missing])
Now I'm stumped and help would be much appreciated.
Thanks
解决方案using Outlook = Microsoft.Office.Interop.Outlook; private void SetRecipientTypeForAppt() { Outlook.AppointmentItem appt = Application.CreateItem( Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem; appt.Subject = "Customer Review"; appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting; appt.Location = "36/2021"; appt.Start = DateTime.Parse("10/20/2006 10:00 AM"); appt.End = DateTime.Parse("10/20/2006 11:00 AM"); Outlook.Recipient recipRequired = appt.Recipients.Add("Ryan Gregg"); recipRequired.Type = (int)Outlook.OlMeetingRecipientType.olRequired; Outlook.Recipient recipOptional = appt.Recipients.Add("Peter Allenspach"); recipOptional.Type = (int)Outlook.OlMeetingRecipientType.olOptional; Outlook.Recipient recipConf = appt.Recipients.Add("Conf Room 36/2021 (14) AV"); recipConf.Type = (int)Outlook.OlMeetingRecipientType.olResource; appt.Recipients.ResolveAll(); appt.Display(false); }
via How to: Create a Meeting Request, Add Recipients, and Specify a Location
这篇关于如何添加使用互操作的新的会议要求Outlook日历?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!