Friday, October 24, 2008

Get Author Email of listitem of Sharepoint list

Here I am giving steps to get email id of user who created item in sharepoint list. I written this code for my custom workflow, so code are written under OnWorkflowActivated_Invoked method.
"SPContext.Current" approach doesn't work in custom workflow code.


public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
private string Originatoremail = "";
private void onWorkflowActivated_Invoked(object sender, ExternalDataEventArgs e)
{
SPFieldUserValue createdby = new SPFieldUserValue(workflowProperties.Web, workflowProperties.Item["Created By"].ToString());
SPUser user = createdby.User;
this.Originatoremail = user.Email;

}


Hope this will help ..

Nilesh

No comments: