web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to pass value from Plugin to CRM Email Template Body

(0) ShareShare
ReportReport
Posted on by

Hi Guys,

I have one custom entity with password field, this field contains the password encryption value.I need to send the password decryption value using dynamics crm email template.I need to know how to pass value from plugin to Email Template body.

Regards,
Dinesh

*This post is locked for comments

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi Dinesh

    There are few ways to get the email generated from a template to have the decryption value populated.

    01. You could add a field to the entity that the email template is based on and set the value to the decryption field (better not to enable auditing on this field) in the plugin just before you generate the email from the template. Once you created the email from the template, clear the decryption field value from the record.

    02. You could have your own unique place holder in the template, instantiate the template in the plugin, find and replace your unique placeholder with the decryption value

  • DineshRaja Profile Picture
    on at

    how to replace emailtemplate placeholder in plugin.

  • Verified answer
    Kokulan Profile Picture
    18,054 on at

    In your code you could instantiate the template and get the email generated using InstantiateTemplateRequest

    InstantiateTemplateRequest instantiateTemplateRequest = new InstantiateTemplateRequest()

               {

                   ObjectId = userId

                     ,

                   ObjectType = "systemuser"

                     ,

                   TemplateId = template.Id

               };

               InstantiateTemplateResponse instantiateTemplateResponse = this.OrganizationService.Execute(instantiateTemplateRequest) as InstantiateTemplateResponse;

               Entity email = instantiateTemplateResponse.EntityCollection.Entities[0];

    the email generated here is not yet saved to the system, so you can get the email body and find and replace your unique place holder with the decryption value.

    Please follow the link below to see how you could work with generated email body.

    github.com/.../CreateCustomEmail.cs

  • DineshRaja Profile Picture
    on at

    ok i take the response of the email and how can i change the placeholder of my email template

  • DineshRaja Profile Picture
    on at

    my placeholder name is [!decrypt]

  • Verified answer
    Kokulan Profile Picture
    18,054 on at

    You could try the following

    email["description"] = email["description"].Replace("[!decrypt]", "YOUR VALUE");

  • DineshRaja Profile Picture
    on at

    Thank You it is working..

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans