创建会议请求、添加收件人并指定位置
该示例创建一个约会项目作为会议请求,指定会议的时间、收件人和位置,并在检查器中显示该约会。
示例
在 Outlook 中,会议请求为 AppointmentItem。 若要将约会项设置为会议请求,必须将 MeetingStatus 属性设置为 olMeeting。 使用 Recipient 对象的 Type 属性可指定与会者是否可选,或者收件人实际上是否为会议资源而非与会者。
如果使用 Visual Studio 测试此代码示例,必须先添加对 Microsoft Outlook 15.0 对象库组件的引用,并在导入 Microsoft.Office.Interop.Outlook 命名空间时指定 Outlook 变量。 不得将 Imports 或 using 语句直接添加到此代码示例中的函数前面,这两个语句必须后跟公共类声明。 下面的代码行演示了如何在 Visual Basic 和 C# 中执行导入和分配。
Imports Outlook = Microsoft.Office.Interop.Outlook
using Outlook = Microsoft.Office.Interop.Outlook;
Private Sub SetRecipientTypeForAppt()
Dim appt As Outlook.AppointmentItem = _
CType(Application.CreateItem( _
Outlook.OlItemType.olAppointmentItem), 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")
Dim recipRequired As Outlook.Recipient = _
appt.Recipients.Add("Ryan Gregg")
recipRequired.Type = _
Outlook.OlMeetingRecipientType.olRequired
Dim recipOptional As Outlook.Recipient = _
appt.Recipients.Add("Peter Allenspach")
recipOptional.Type = _
Outlook.OlMeetingRecipientType.olOptional
Dim recipConf As Outlook.Recipient = _
appt.Recipients.Add("Conf Room 36/2021 (14) AV")
recipConf.Type = _
Outlook.OlMeetingRecipientType.olResource
appt.Recipients.ResolveAll()
appt.Display(False)
End Sub
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);
}