Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Dynamic values and hyper links in email

Posted on by 12,070 Super User 2024 Season 1

Hi all,

I need to send an email alerts between users using templates. I have below body:

Work Order <Work Order Number> has been assigned to you. In order to see the details please click the following link:

<link to booking>

 

I am using global templates to send an email. My code is below:

 

public static void Email(Guid To, Guid From)
{
Entity entity = GetGlobalTemplate("Marketing communication unsubscribe acknowledgement", service);
if (entity.Id != null)
{
Entity email = new Entity();
email.LogicalName = "email";
//to - Guid
List<Entity> ToEntities = new List<Entity>();
Entity activityPartyforTo = new Entity();
activityPartyforTo.LogicalName = "activityparty";
activityPartyforTo.Attributes["partyid"] = new EntityReference(EntityName.systemUser, To);
ToEntities.Add(activityPartyforTo);
email.Attributes["to"] = ToEntities.ToArray();
//from - Guid
List<Entity> FromEntities = new List<Entity>();
Entity activityPartyforFrom = new Entity();
activityPartyforFrom.LogicalName = "activityparty";
activityPartyforFrom.Attributes["partyid"] = new EntityReference(EntityName.systemUser, From);
FromEntities.Add(activityPartyforFrom);
email.Attributes["from"] = FromEntities.ToArray();

email.Attributes["regardingobjectid"] = new EntityReference(EntityName.bookableResourceBooking, recordId);


var emailUsingTemplateReq = new SendEmailFromTemplateRequest

{

Target = email,

TemplateId = entity.Id,

RegardingId = ((EntityReference)entity[bookableResourceBookingAttributes.createdBy]).Id,

RegardingType = EntityName.systemUser

};

var emailUsingTemplateResp = (SendEmailFromTemplateResponse)service.Execute(emailUsingTemplateReq);
}
}

How should I make red highlighted to dynamic? When I go to the template it is showing me only users values. When I go to the template types it is showing other values. 

Thanks 

Regards,

AW

*This post is locked for comments

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans