Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Retrieving Email Title using Guid of Email Template.

Posted on by Microsoft Employee
Hello Everyone,

I want to retrieve the email title through Guid of the template. Is there any way I can get the titles?

here is my code. I am also filtering the templates.


public static void TemplateLogic(IOrganizationService service, string selected_option)
        {
            var queryBuildInTemplates = new QueryExpression
            {
                EntityName = "template",
                ColumnSet = new ColumnSet("templateid", "templatetypecode"),
                Criteria = new FilterExpression()

            };

            
            
            queryBuildInTemplates.Criteria.AddCondition("templatetypecode",
             ConditionOperator.Equal, "contact");
            EntityCollection templateEntityCollection = service.RetrieveMultiple(queryBuildInTemplates);
}
  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Retrieving Email Title using Guid of Email Template.

    HI,

    Use below code to get Title and Subject of an Email Template.

    var queryBuildInTemplates = new QueryExpression
                    {
                        EntityName = "template",
                        ColumnSet = new ColumnSet(true),
                        Criteria = new FilterExpression()
    
                    };
                    queryBuildInTemplates.Criteria.AddCondition("templatetypecode",
                     ConditionOperator.Equal, "contact");
                    EntityCollection templateEntityCollection = crmSvc.RetrieveMultiple(queryBuildInTemplates);
    
                    foreach (Entity emailTemplate in templateEntityCollection.Entities)
                    {
                        Console.WriteLine("Template Title:"   emailTemplate["title"].ToString());
                        Console.WriteLine("Template Subject:" emailTemplate["subject"].ToString());
                    }

    Result :-

    4150.CQ26.PNG

    Please mark my answer verified if i were helpful

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans