Creating an Appointment with the Pocket Outlook Object Model
Question: Using Window Mobile 5 I understand that I can access the Outlook Object model using managed code. One of the requirements for the application that we are writing is that we need to create appointments as part of the application. Do you have an example of this how this can be done?
Answer: Windows Mobile 5 now exposes a managed object model for Pocket Outlook. These classes are available through the Microsoft.WindowsMobile.PocketOutlook namespace. You can use the following steps to create an appointment using this namespace.
Note: before trying this code make sure that you have the Windows Mobile 5 SDK installed. More information can be found here.
- Create a new Device project as shown above.
- Make sure you are using the Windows Mobile Pocket 5 Pocket PC SDK. If you are not sure use the Project – Change Target Platform to validate your platform as shown above.
- Drop a button on the emulator as shown above.
- Using the My Project set a reference to the Microsoft.WindowsMobile.Telephony as shown above.
Behind the button enter the following code:
Imports Microsoft.WindowsMobile.PocketOutlook
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CalAppt As New Appointment
With CalAppt
' set the appointment detail
.Subject = "Windows Mobile 5 Presentation"
.Body = "Present to the customer all the cool things that you can do with Windows Mobile 5"
.Start = New Date(2006, 1, 23, 11, 0, 0)
.Duration = New TimeSpan(1, 0, 0)
' set the reminders
.ReminderRepeat = True
.ReminderVibrate = True
End With
' add the appointment to Outlook
Dim OutSession As New OutlookSession
With OutSession
.Appointments.Items.Add(CalAppt)
End With
End Sub
End Class
Now you can run the application. When starting the application select the Windows Mobile 5 Pocket PC Phone Emulator as shown below.
Once the application is started select the button and then check the calendar to confirm that the appointment has been made.
Comments
- Anonymous
February 13, 2006
Question: My company is in the process of developing an Windows Mobile 5 mobile application. One of...