CH3COOH(酢酸)が.NET FrameworkやWindows Mobileの事を始め、日々情報を発信中!

スケジュール(予定)を追加する

.NET Compact Frameworkからは、Microsoft.WindowsMobile.PocketOutlook名前空間のOutlookクラスを使用する事 で、Outlook Mobileで記録した連絡先や予定、仕事などのプライベートな情報へ簡単にアクセスする事が出来ます。

ここでは、スケジュール(予定)を追加する方法をご紹介します。

    ' Imports Microsoft.WindowsMobile.PocketOutlook

    Private Sub Button1_Click(ByVal sender As System.Object, _
                              ByVal e As System.EventArgs)

        ' 予定を作成し、詳細を設定する
        Dim appointment As New Appointment()

        ' 件名を設定する
        appointment.Subject = "スマートフォン勉強会"

        ' 予定の開始を 2009 年 5 月 16 日、13:00 に設定する
        appointment.Start = New DateTime(2009, 5, 16, 13, 0, 0)

        ' 予定は 5 時間で終了する
        appointment.Duration = New TimeSpan(5, 0, 0)

        ' デバイスの振動を使用してリマインダを発行する
        appointment.ReminderVibrate = True

        ' ユーザーが解除するまでリマインダを繰り返す
        appointment.ReminderRepeat = True

        ' Outlookセッションの作成し、
        ' 予定を Outlook の予定表フォルダに追加する
        Using outlook As New OutlookSession()
            outlook.Appointments.Items.Add(appointment)
        End Using

    End Sub
    // Imports Microsoft.WindowsMobile.PocketOutlook
    
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        // 予定を作成し、詳細を設定する
        Appointment appointment = new Appointment();
        
        // 件名を設定する
        appointment.Subject = "スマートフォン勉強会";
        
        // 予定の開始を 2009 年 5 月 16 日、13:00 に設定する
        appointment.Start = new DateTime(2009, 5, 16, 13, 0, 0);
        
        // 予定は 5 時間で終了する
        appointment.Duration = new TimeSpan(5, 0, 0);
        
        // デバイスの振動を使用してリマインダを発行する
        appointment.ReminderVibrate = true;
        
        // ユーザーが解除するまでリマインダを繰り返す
        appointment.ReminderRepeat = true;
        
        // Outlookセッションの作成し、
        // 予定を Outlook の予定表フォルダに追加する
        using (OutlookSession outlook = new OutlookSession()) {
            outlook.Appointments.Items.Add(appointment);            
        }
    }

上記のサンプルコードの実行画面。

スケジュール(予定)を追加する

参照:OutlookSession Class (Microsoft.WindowsMobile.PocketOutlook)


Copyright(C) since 2008 CH3COOH(酢酸). All Rights Reserved.