【发布时间】:2016-02-25 18:02:29
【问题描述】:
我想创建一个程序,可以在其他人的 Outlook 日历中创建约会。例如:如果有人要求他们的老板免费五天,他们的老板需要能够批准并立即在该人的 Outlook 日历中显示。我已经编写了一些代码,允许您设置自己的约会。这是我的代码:
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
AddAppointment("ConferenceRoom #2345", "We will discuss progression the group project.", "Group Project", new DateTime(2016, 02, 23, 15, 30, 52), new DateTime(2016, 02, 23, 20, 30, 52));
}
private void AddAppointment(string location, string body, string subject, DateTime startdatum, DateTime einddatum)
{
try
{
var AppOutlook = new Outlook.Application();
Outlook.AppointmentItem newAppointment =
(Outlook.AppointmentItem)
AppOutlook.CreateItem(Outlook.OlItemType.olAppointmentItem);
newAppointment.Start = startdatum;
newAppointment.End = einddatum;
newAppointment.Location = location;
newAppointment.Body = body;
newAppointment.BusyStatus=Outlook.OlBusyStatus.olTentative;
newAppointment.AllDayEvent = true;
newAppointment.Subject = subject;
newAppointment.Save();
newAppointment.Display(true);
}
catch (Exception ex)
{
MessageBox.Show("The following error occurred: " + ex.Message);
}
}
PS:对不起,如果我的英语不好。
【问题讨论】:
-
如何将员工添加为必需的与会者? (见msdn.microsoft.com/en-us/library/office/ff867639.aspx)
-
一种需要更多时间的方法是使用 EWS(我已经使用过它,效果很好,但您可能会遇到权限问题),例如,请参阅this question on how to do它:stackoverflow.com/questions/2419651/…
-
如果我将某人添加为必需的与会者,我想这个人的空闲天数也会在老板的日历中设置
-
是的,没错。但在我的公司,几乎每个老板都希望在他们的员工休假时看到他们的日历