0

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 http://davesquared.net/2007/07/sending-email-to-group-with-sharepoint.html 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()
    {
        InitializeComponent();
    }

    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
    {
        get
        {
            return (WorkflowContext)base.GetValue(_ContextProperty);
        }
        set
        {
            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 = "donotreplay.com";
        this.sendAutomatedEmail.Body = "Title :" + workflowProperties.Item["Title"];
    }
} 
1

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. http://msdn.microsoft.com/en-gb/library/microsoft.sharepoint.workflowactions.applyactivation.aspx

http://social.technet.microsoft.com/forums/en-US/sharepointdevelopmentprevious/thread/e7236d96-133a-42fa-8227-dabb4a70d767

0

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 http://davesquared.net/2007/07/sharepoint-aware-workflow-activities.html for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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