Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8442855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:57:17+00:00 2026-06-10T08:57:17+00:00

I want to create a template with XML or HTML with placeholders for exception

  • 0

I want to create a template with XML or HTML with placeholders for exception reporting variables to be swapped in at runtime when an exception occurs. I like what I’ve got so far with the template, and behavior, but it’s all hard coded at the moment, so bad.

Here’s a sample of the code I have…

'Styling (Outlook does not follow CSS standards >:-( )
body = "<html><head>" & _
        "<style type=""text/css"">" & _
        "   * {font:12px Arial, Helvetica, sans-serif;}" & _
        "   table {border-collapse:collapse;}" & _
        "   table.grid td {padding:0 7px;border:solid #ccc 1px;}" & _
        "   .bold {font-weight:bold;padding-right:12px;}" & _
        "</style></head><body>"

'Partial template
body &= "<table><tr><td class=""bold"">Error:</td><td>" & ex.Message & "</td></tr>" & _
        "<tr><td class=""bold"">Exception:</td><td>" & ex.GetType().FullName & "</td></tr>" & _
        "<tr><td class=""bold"">Source:</td><td>" & ex.Source & "</td></tr>" & _
        "<tr><td class=""bold"">Request Url:</td><td>" & Request.Url.ToString & "</td></tr></table><br />"

Notice the ex.Message variable, etc. I want to move all the HTML code into a separate file (XML or HTML, depending on what is recommended, XML I imagine?) along with placeholders for each of the error variables. Then load the template, substitute in the variables and send the email on the fly. What is the best practice for doing this?

Also, please don’t try to fix my CSS, that’s not what this question is about. Outlook doesn’t follow standards (go figure), and this is how I had to do it.

Thanks. 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:57:18+00:00Added an answer on June 10, 2026 at 8:57 am

    I think you are pretty much on the right way. The steps would be:

    • Extract the templates into a resource file (the resource extension .xml, .html is the actual resource type).
    • Replace the variable concatenations with tokens; So would be:
      (…)<tr><td class="bold">Source:</td><td>{exSource}</td></tr>(…)
    • Create an extension method to String objects to “enhance” the String.Format, so you could do something like

      ' Load the resourceFile and put content into formattedBody
      Dim formattedBody as String = templateBody.FormatWith(New With{.exSource = ex.Source})
      

    About how to implement the FormatWith, take a look here.
    This answer may help you as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a custom template engine like velocity or freemarker which will
I want to create a template class (let's call it Foo ) that only
I want to create a template class in C#, for example: public class Foo<T>
I want to create a template for a component that is used many times
I want to create a Visual Studio Item Template that generates an Item (for
I want to create a block and add that block to my template via
Basically, I want an exact copy of the XML, except I'd like to sort
I want to export objects to XML and create XSD. following are the base
for performance testing purposes I want to take a small XML file and create
I want to create a ASP.NET user control from an XML using XSLT. Currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.