So, Pocket Outlook is really easy. You just add a reference to Microsoft.WindowsMobile and Microsoft.WindowsMobile.PocketOutlook. (Right click on your project, select Add Reference, and make sure you are at the .Net tab and click them.
Here’s the code to get things started:
Dim polApp As Microsoft.WindowsMobile.PocketOutlook.OutlookSession = New outlook.OutlookSession
To go through each task, here is the code:
Dim oItems As outlook.TaskCollection
Dim otask As outlook.Task
oItems = polApp.Tasks.Items
Dim i As Integer
For i = 0 To oItems.Count – 1
oTask = oItems(i)
If oTask.Subject = "Change Infusion Set" Then
otask.Complete = True
otask.Update()
End If
Next
polApp.Dispose() ‘not sure if it is needed
Note that you have to save both the Items collection and the item you are looking at. If you don’t save the item you are looking at, you won’t update the item itself. Weird, but them’s the rules.
Finally, the code to set up a task:
‘Create a new outlook item
otask = New outlook.Task
otask.Subject = "Change Infusion Set"
otask.Body = "Change Infusion Set"
otask.StartDate = strDate
otask.DueDate = strDate
otask.Complete = False
otask.Categories = "Medical"
Dim StrTime As String
If Me.DateTimePicker1.Value <> Nothing Then
If reminder = True Then
Me.lblResults.Text = "In Reminder"
otask.ReminderSet = True
StrTime = Convert.ToString(Me.DateTimePicker1.Value.TimeOfDay)
otask.ReminderTime = Convert.ToDateTime(strDate & " " & StrTime)
otask.Complete = False
Else
otask.ReminderSet = False
End If
End If
‘ Save to Tasks
polApp.Tasks.Items.Add(otask)
‘ lblResults.Text = "Task has been created for " & strDate
End Sub
Leave a Reply