Simple Activity 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.
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.
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.
This project is a workflow console application where the SendEmailActivityLibrary is used. The To property is set to firstname.lastname@example.org, and the From property is set to email@example.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:
To build the sample
Download the sample by clicking Download Sample.
This extracts the sample project to your local hard disk.
Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.
Go to the source directory of the sample.
At the command prompt, type MSBUILD <Solution file name>.
To run the sample
In the SDK Command Prompt window, run the .exe file in the WorkflowConsoleApplication\bin\debug folder (or the WorkflowConsoleApplication \bin folder for the VB version of the sample), which is located below the main folder for the sample.