Создание приглашения на собрание, добавление получателей и указание расположения
В этом примере создается элемент "встреча" в качестве приглашения на собрание, задаются время, получатели и место собрания, а затем назначенная встреча показывается в инспекторе.
Пример
В Outlook приглашение на собрание представлено объектом AppointmentItem. Чтобы сделать элемент встречи приглашением на собрание, необходимо задать для свойства MeetingStatus значение olMeeting. Используйте свойство Type объекта Recipient , чтобы указать, является ли участие в собрании необязательным, или получатель фактически является ресурсом собрания, а не его участником.
Если вы используете Visual Studio для тестирования этого примера кода, сначала добавьте ссылку на компонент библиотеки объектов Microsoft Outlook 15.0 и задайте переменную Outlook при импорте пространства имен Microsoft.Office.Interop.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);
}