Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to format email description in a table or line by line using c#

Posted on by 4,440

Hi 

I am retrieving crm records and sending email to users using c#. How can I format description to show records line by line or in table format ?

email["subject"] = "Contact Created This Week";

email["description"] = FL;

Fl is the string list containing record names. Thanks

*This post is locked for comments

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: How to format email description in a table or line by line using c#

    Hi

    You could build build the table as shown below

    List<string> names = new List<string>(new string[] {"Name 1", "Name 2"});

    StringBuilder nameList = new StringBuilder();

    nameList.Append("<table><tr><th>Name</th></tr>");

    foreach (var name in names)

    {

    nameList.Append($"<tr><td>{name} </td></tr>");

    }

    nameList.Append("</table>");

         email["description"] = nameList;

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: How to format email description in a table or line by line using c#

    StringBuilder description = new StringBuilder();

    description.Append("Dear Customer <br/> <br/>");

    description.Append("Wish you a very happy birthday and great life ahead. <br/> <br/>");

    description.Append("Regards, <br/>");

    description.Append("Rawish");

    description will be :  

    Dear Customer

    Wish you a very happy birthday and great life ahead.

    Regards,

    Rawish

  • Suggested answer
    naresh babu Profile Picture
    naresh babu 425 on at
    RE: How to format email description in a table or line by line using c#

    If you want in table format, then you should go with html in C# by using string builder.

    For you reference, Please go through below link.

    dynamicspeople.wordpress.com/.../how-to-send-dynamic-html-formatted-table-in-email-body

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans