次の方法で共有


方法: プログラムによってカスタムの予定表を作成する

この例では、PersonalCalendar という名前の新しい予定表フォルダーを作成し、新しい予定アイテムを作成して、予定表フォルダーに追加します。その後、その予定表フォルダーを表示します。

対象: このトピックの情報は、Outlook 2013 と Outlook 2010 のアプリケーション レベルのプロジェクトに適用されます。詳細については、「Office アプリケーションおよびプロジェクト タイプ別の使用可能な機能」を参照してください。

使用例

Private Sub CreateCustomCalendar()
    Const newCalendarName As String = "PersonalCalendar"
    Dim primaryCalendar As Outlook.MAPIFolder = _
        Me.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook _
        .OlDefaultFolders.olFolderCalendar)
    Dim needFolder As Boolean = True
    For Each personalCalendar As Outlook.MAPIFolder In _
        primaryCalendar.Folders()
        If personalCalendar.Name = newCalendarName Then
            needFolder = False
        End If
    Next
    If needFolder Then
        Dim personalCalendar As Outlook.MAPIFolder = _
            primaryCalendar.Folders.Add(newCalendarName)
        Dim newEvent As Outlook.AppointmentItem = _
            personalCalendar.Items.Add _
            (Outlook.OlItemType.olAppointmentItem)
        With newEvent
            .Start = Date.Now.AddHours(1)
            .End = Date.Now.AddHours(1.25)
            .Subject = "New plan"
            .Body = "Meet to discuss new plan."
            .Save()
        End With
    End If
    Me.Application.ActiveExplorer().SelectFolder(primaryCalendar _
        .Folders(newCalendarName))
    Me.Application.ActiveExplorer().CurrentFolder.Display()
End Sub
Private Sub CreateCustomCalendar()
    Const newCalendarName As String = "PersonalCalendar"
    Dim primaryCalendar As Outlook.MAPIFolder = _
        Me.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook _
        .OlDefaultFolders.olFolderCalendar)
    Dim needFolder As Boolean = True
    For Each personalCalendar As Outlook.MAPIFolder In _
        primaryCalendar.Folders()
        If personalCalendar.Name = newCalendarName Then
            needFolder = False
        End If
    Next
    If needFolder Then
        Dim personalCalendar As Outlook.MAPIFolder = _
            primaryCalendar.Folders.Add(newCalendarName)
        Dim newEvent As Outlook.AppointmentItem = _
            personalCalendar.Items.Add _
            (Outlook.OlItemType.olAppointmentItem)
        With newEvent
            .Start = Date.Now.AddHours(1)
            .End = Date.Now.AddHours(1.25)
            .Subject = "New plan"
            .Body = "Meet to discuss new plan."
            .Save()
        End With
    End If
    Me.Application.ActiveExplorer().SelectFolder(primaryCalendar _
        .Folders(newCalendarName))
    Me.Application.ActiveExplorer().CurrentFolder.Display()
End Sub
private void CreateCustomCalendar()
{
    const string newCalendarName = "PersonalCalendar";
    Outlook.MAPIFolder primaryCalendar = (Outlook.MAPIFolder)
        this.Application.ActiveExplorer().Session.GetDefaultFolder
         (Outlook.OlDefaultFolders.olFolderCalendar);
    bool needFolder = true;
    foreach (Outlook.MAPIFolder personalCalendar
        in primaryCalendar.Folders)
    {
        if (personalCalendar.Name == newCalendarName)
        {
            needFolder = false;
            break;
        }
    }
    if (needFolder)
    {
        Outlook.MAPIFolder personalCalendar = primaryCalendar
            .Folders.Add(newCalendarName,
                Outlook.OlDefaultFolders.olFolderCalendar);
        Outlook.AppointmentItem newEvent =
            personalCalendar.Items.Add
            (Outlook.OlItemType.olAppointmentItem)
            as Outlook.AppointmentItem;
        newEvent.Start = DateTime.Now.AddHours(1);
        newEvent.End = DateTime.Now.AddHours(1.25);
        newEvent.Subject = "New plan";
        newEvent.Body = " Meet to discuss new plan.";
        newEvent.Save();
    }
    Application.ActiveExplorer().SelectFolder(primaryCalendar
        .Folders[newCalendarName]);
    Application.ActiveExplorer().CurrentFolder.Display();
}
private void CreateCustomCalendar()
{
    const string newCalendarName = "PersonalCalendar";
    Outlook.MAPIFolder primaryCalendar = (Outlook.MAPIFolder)
        this.Application.ActiveExplorer().Session.GetDefaultFolder
         (Outlook.OlDefaultFolders.olFolderCalendar);
    bool needFolder = true;
    foreach (Outlook.MAPIFolder personalCalendar
        in primaryCalendar.Folders)
    {
        if (personalCalendar.Name == newCalendarName)
        {
            needFolder = false;
            break;
        }
    }
    if (needFolder)
    {
        Outlook.MAPIFolder personalCalendar = primaryCalendar
            .Folders.Add(newCalendarName,
                Outlook.OlDefaultFolders.olFolderCalendar);
        Outlook.AppointmentItem newEvent =
            personalCalendar.Items.Add
            (Outlook.OlItemType.olAppointmentItem)
            as Outlook.AppointmentItem;
        newEvent.Start = DateTime.Now.AddHours(1);
        newEvent.End = DateTime.Now.AddHours(1.25);
        newEvent.Subject = "New plan";
        newEvent.Body = " Meet to discuss new plan.";
        newEvent.Save();
    }
    Application.ActiveExplorer().SelectFolder(primaryCalendar
        .Folders[newCalendarName]);
    Application.ActiveExplorer().CurrentFolder.Display();
}

参照

処理手順

方法: プログラムによって予定を作成する

方法: プログラムによって会議出席依頼を作成する

概念

予定表アイテムの操作