using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Services;
using System.Text;
using System.Threading.Tasks;
namespace UpdateOpportunityProduct
{
public class UpdateOpportunityProduct : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
//Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context.MessageName != "Update")
return;
//Get a reference to the Organization service.
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
//Extract the tracing service for use in debugging sandboxed plug-ins
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
//Entity Name
Entity userSetting = new Entity("usersettings");
//Guid Of the user record
Guid userId = default(Guid);
userSetting.Id = userId;
//Attribute to set value of “Allow other Microsoft Dynamics 365 user to send email on your behalf”
userSetting["issendasallowed"] = true;
//Update the Record
service.Update(userSetting);
}
}
}
above is my following code and I have built it and trying to register as a post image so that each time when the owner is changed, through plugin it automatically allows that option to send email


I am not getting the option to register
[quote user="LA"]
not a direct answer regarding plugin, btu just in case you were not aware, it is possible to set user personal settings via Power Automate / Flow. (we do it for the users TimeZone as users are always created for us based on the Server and we are technically in a different timezone to the instances server).
[/quote]