Create Workflow Activity using Visual Studio 2010 in SharePoint 2010

This SharePoint 2010 workflow tutorial explains, how to create a workflow activity using Visual Studio 2010 in SharePoint 2010. We will use visual studio 2010 for creating a workflow activity in SharePoint 2010.

1. First, we create the Sequential workflow using visual studio. Before proceeding check,
Create a Sequential workflow using Visual Studio 2010 in SharePoint 2010

2. Now we are going to create the Activity using visual studio 2010.

3. Now open Workflow1.cs [Design] created by step 1.

4. Go to toolbox, drag and drop the SendEmail activity from SharePoint Workflow section.

5. Go to sendEmail1 properties and select the CorrelationToken as workflowToken and in the OwnerActivityName select workflow1. See in fig

create workflow activity

create a workflow activity

6. Now we need to set the To property, click on the …button in the To property.

7. Click on Bind to a new member tab, select Create Field option and then click on ok. See in fig

create custom workflow activity sharepoint 2010 visual studio

create custom workflow activity SharePoint 2010 visual studio

8. Similarly set the Subject and Body Property.

9. Now see the sendEmail1 properties. See in fig

create workflow activity visual studio

create workflow activity visual studio

10. Following the code of Workflow1.cs

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;

namespace WorkflowProject1.Workflow1
public sealed partial class Workflow1 : SequentialWorkflowActivity
public Workflow1()

public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();

public String sendEmail1_To1 = default(System.String);
public String sendEmail1_Subject1 = default(System.String);
public String sendEmail1_Body1 = default(System.String);

private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)


private void sendEmail1_MethodInvoking(object sender, EventArgs e)
sendEmail1_To1 = “”;
sendEmail1_Subject1 = “Testing for email activity”;
sendEmail1_Body1 = “Here we testing the email activity using visual studio 2010”;

11. Now deploy the solution.

12. Now for testing go to the custom list where the workflow is associated by default. Create a new item. A mail will be sent to the mentioned user.

You may like following SharePoint 2010 workflow tutorials:

Hope this SharePoint workflow tutorial helps to create a Workflow Activity using Visual Studio 2010 in SharePoint 2010.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

Navneet Singh

I am Navneet Singh, Working at C3it software solutions pvt. ltd. in Pune. My core skills are SharePoint 2013, Office 365, SharePoint 2010, SharePoint Designer, SharePoint Designer Workflow, Nintex Workflow, Infopath, Webpart, CSOM/SSOM, Power-shell, C#, ASP.NET and SQL Server.