Create Workflow Activity using Visual Studio 2010 in SharePoint 2010

create workflow activity
InfoPath alternatives for form designing SharePoint

In this post we will discuss how to create a workflow activity using Visual Studio 2010 in SharePoint 2010.

Also you can check out:

– Use list column for Globally reusable workflow for list action in SharePoint 2010

– Creating Multiple Tasks from a SharePoint 2010 Workflow

– Download a FREE PDF on SharePoint online tutorial

1. First we create the Sequential workflow using visual studio. For this follow this link
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 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()
{
InitializeComponent();
}

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 = “navneet.singh@abc.com”;
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.

Similar SharePoint 2013 Tutorials


About 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.

View all posts by Navneet Singh →

Leave a Reply