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"];
}
}