SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a newbie in the custom workflow development. The scenario I want to send an email notification to the group when an item is created in the list. I am referring to Depending on the above explanation I wrote the below code, however the _Context object is always null "var _NameToEmailResolver = new NameToEmailResolver(_Context);"

Any thoughts on why _Context is null, and how to get the workflow context. below is the code which i implemented. is it required to have more than 1 dependency property to achieve below functionality. Will appreciate if any one helps with this.

public sealed partial class Workflow1 : SequentialWorkflowActivity
    public Workflow1()

    public Guid workflowId = default(System.Guid);
    public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
    public static DependencyProperty _ContextProperty = DependencyProperty.Register("_Context", typeof(WorkflowContext), typeof(Workflow1));
    public WorkflowContext _Context
            return (WorkflowContext)base.GetValue(_ContextProperty);
            base.SetValue(_ContextProperty, value);

    private void createEmailMessage_ExecuteCode(object sender, EventArgs e)

        var _NameToEmailResolver = new NameToEmailResolver(_Context);

        string _Group = workflowProperties.Item["Assignee"].ToString();
       _Group=_Group.Split(new char[] { ';' })[1].Remove(0,1);
        this.sendAutomatedEmail.To = _NameToEmailResolver.GetEmailAddressesFromName(_Group);
        this.sendAutomatedEmail.From = "";
        this.sendAutomatedEmail.Body = "Title :" + workflowProperties.Item["Title"];
share|improve this question

You might need the ApplyActivation activity in the designer in Visual Studio.

Set the __Context to your WorkflowContext _Context property and the __WorkflowProperties to workflowProperties field.

This initialises the context.

share|improve this answer

You may need to pass in the context parameter in the .ACTIONS file, add the following to the <parameters> section:

<Parameter Direction="In" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Name="__Context" />

See for details.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.