1 '---------------------------------------------------------------------
2 ' This file is part of the Windows Workflow Foundation SDK Code Samples.
4 ' Copyright (C) Microsoft Corporation. All rights reserved.
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.
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
14 '---------------------------------------------------------------------
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
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
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
54 Return ActivityExecutionStatus
.Closed