ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
//get the execution context from the service provider
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
//obtain the org service ref to make web service calls
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
try
{
Entity target = (Entity)context.InputParameters["target"];
Entity objUser = service.Retrieve("systemuserid", userGuid, new ColumnSet("primaryemailaddress", "systemuserid"));
if (objUser != null && objUser.Contains("primaryemailaddress") && objUser["primaryemailaddress"] != null)
{
string Useremail = (string)objUser["primaryemailaddress"];
}
}
catch (Exception ex)
{
throw (ex);
}
}