Simple Activity Sample

Download sample

This sample illustrates how to add dependency properties to a custom activity. It also shows how to define an event on a custom activity, and how code-beside can be used to handle that event.

The sample demonstrates how to create a SendEmail activity. This custom activity exposes To and From properties. Additionally, the SendEmail activity is used in a sequential workflow to demonstrate its use.

Sample Projects

The sample consists of two projects:

  • SendEmailActivityLibrary holds the implementation of the SendEmail custom activity.

  • WorkflowConsoleApplication is the workflow in which the custom activity is used.

SendEmailActivityLibrary

This project is a workflow activity library that generates the SendEmail custom activity. The custom activity has two properties, To and From, representing the recipient and the sender of the e-mail respectively. Additionally, the custom activity has a BeforeSendEvent event.

The execution logic of the custom activity is implemented in the SendEmail activity's partial class in SendEmailCustomActivity.cs. It should contain the SendEmail execution logic. The OnBeforeSend event is raised from within the method.

WorkflowConsoleApplication

This project is a workflow console application where the SendEmailActivityLibrary is used. The To property is set to recipient@fabrikam.com, and the From property is set to *sender@*contoso.com. The custom activity's OnBeforeSend event handler prints a message to the console.

When you run the sample, you should see an output similar to the following:

Output from Simple Activity sample

To build the sample

  1. Download the sample by clicking Download Sample.

    This extracts the sample project to your local hard disk.

  2. Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.

  3. Go to the source directory of the sample.

  4. At the command prompt, type MSBUILD <Solution file name>.

To run the sample

  1. In the SDK Command Prompt window, run the .exe file in the WorkflowConsoleApplication\bin\debug folder (or the WorkflowConsoleApplication \bin folder for the Visual Basic version of the sample), which is located below the main folder for the sample.

See Also

Other Resources

Basic Activity Designer Sample
Custom Activities Samples
Creating Custom Activities

© 2007 Microsoft Corporation. All rights reserved.