Plugin: Validate before Sending Email


To Validate the Email Message before sending email, then we can create the Plugin on “Send” Message.

For Email Send Plugin, We will not get the key “Target” in Input Parameters instead we will get the “EmailId” which is GUID of the email record. In order to get all the attributes of the email, you can register the Pre-Image.

if (context.InputParameters.Contains(“EmailId”) && context.InputParameters[“EmailId”] != null)

{

var emailId = (Guid)context.InputParameters[“EmailId”];

Entity entity = context.PreEntityImages.Contains(“preImage”) ? (Entity)context.PreEntityImages[“preImage”] : null;

if (entity.LogicalName != Xrm.Email.EntityLogicalName)

return;

//Logic Here

}

 

Advertisements

About Kishore Dhanekula

MS Dynamics CRM and .NET Architect
This entry was posted in MS Dynamics CRM 2016. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s