added samples
[windows-sources.git] / sdk / samples / WFSamples / Applications / OutlookWorkflowWizard / VB / ReadEmailActivity / OutlookTask.vb
blobd99f317248bedd7b73cd392e667686d4d3a86643
1 '---------------------------------------------------------------------
2 ' This file is part of the Windows Workflow Foundation SDK Code Samples.
3 '
4 ' Copyright (C) Microsoft Corporation. All rights reserved.
5 '
6 'This source code is intended only as a supplement to Microsoft
7 'Development Tools and/or on-line documentation. See these other
8 'materials for detailed information regarding Microsoft code samples.
9 '
10 'THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
11 'KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12 'IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
13 'PARTICULAR PURPOSE.
14 '---------------------------------------------------------------------
16 Imports System
17 Imports System.Workflow.ComponentModel
18 Imports System.Windows.Forms
19 Imports Outlook = Microsoft.Office.Interop.Outlook
20 Imports System.Workflow.Activities
22 Public Class OutlookTask
23 Inherits BaseOutlookItem
25 Protected Overrides Function Execute(ByVal executionContext As System.Workflow.ComponentModel.ActivityExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus
27 ' Create an Outlook Application object.
28 Dim outlookApp As Outlook.Application = New Outlook.Application()
29 ' Create a new TaskItem.
30 Dim NewTask As Outlook.TaskItem = CType(outlookApp.CreateItem(Outlook.OlItemType.olTaskItem), Outlook.TaskItem)
31 ' Configure the task at hand and save it.
32 NewTask.Body = "Workflow Generated Task"
33 NewTask.DueDate = DateTime.Now
34 NewTask.Importance = Outlook.OlImportance.olImportanceHigh
35 Dim dummy As Activity
37 If TypeOf Me.Parent.Parent Is ParallelActivity Then
38 dummy = Me.Parent.Parent.Parent.Activities.Item(1)
39 If Not (CType(dummy, DummyActivity).Title = "") Then
40 MessageBox.Show("Creating Outlook Task")
41 NewTask.Subject = CType(dummy, DummyActivity).Title
42 NewTask.Save()
43 End If
44 End If
45 If TypeOf Me.Parent.Parent Is SequentialWorkflowActivity Then
46 dummy = Me.Parent.Parent.Activities.Item(1)
47 If Not (CType(dummy, DummyActivity).Title = "") Then
48 MessageBox.Show("Creating Outlook Task")
49 NewTask.Subject = CType(dummy, DummyActivity).Title
50 NewTask.Save()
51 End If
52 End If
54 Return ActivityExecutionStatus.Closed
55 End Function
56 End Class