
Workflows can be created using Share point designer easily, but the thing is, it has only a set of Pre-defined activities. If we want to create our own activity, then we can use Custom Workflows which can be created with the help Workflow Foundation in VS 2008. This article explains a simple custom workflow with a custom workflow initiation form to collect certain data and pass it to the workflow.

The workflow looks like as above, Now we can write our c# code to send an email to a particular person.
Consider that we have a pass the Sender mail id as parameter to this work flow which can be selected dynamically by the user. We can add an aspx page in our project with required controls like a drop down (contains the list of Sender mail ids) and a Send Button and use it as an initiation form.
In the above example we have created a custompage.aspx (refer the figure above), while form loading we are loading items of the drop down control from the WSS list. To make sure that this page is called during the workflow initiation pls use the following in the workflow.xml file.
Under the <Workflow> tag add the following code.
InstantiationUrl = "_layouts/SampleSequentialWorkFlow.aspx"
which informs WSS to use our instantiation form when the Workflow is activated.
Then On the Button click event we have to write the follow code to pass the selected email id from the drop down to the workflow as a string.
Accessing the initiation parameters in the sharepoint workflow code
In the Workflowload activity we can use the fllowing code and get the parameter values
public SPWorkflowActivationProperties workflowProperties = newSPWorkflowActivationProperties();
String ParamValue = workflowProperties.AssociationData;
Remember that values passed in the “StartWorkflow” is accessed at this stage for our processing.
Add a intall.bat file which contains the following code to register the workflow that we created in the WSS 3.0
Intall.bat contains
@SET TEMPLATEDIR="c:\program files\common files\microsoft shared\web server extensions\12\Template"
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"
Echo Copying files
xcopy /e /y TEMPLATE\* %TEMPLATEDIR%
Echo Installing feature
%STSADM% -o InstallFeature -filename CustomWorkFlow\feature.xml -force
Echo Restart IIS Worker Process
IISRESET
Also incude the following code in application propertie’s Post Build Event
cd $(ProjectDir)
Install.bat
Now on every build, the Workflow will be deployed in the WSS for to access and test.