title: String.Format failing on style section of HTML Email Template
body: <p>I am sending HTML email template using Bodybuilder and a mail sending service.  I used this link learn.</p>
  <p><a href="https://www.c-sharpcorner.com/article/send-email-using-templates-in-asp-net-core-applications/" rel="nofollow noreferrer">https://www.c-sharpcorner.com/article/send-email-using-templates-in-asp-net-core-applications/</a></p>
  <p>Anyway, I created my email template using an external service (<a href="https://topol.io/" rel="nofollow noreferrer">https://topol.io/</a>).</p>
  <p>It is giving me errors when I try to use the generated HTML file with the String.FOrmat command referenced in the first link.  I finally figured out it is this section of code causing the String.Format to fail.</p>
  <p>This is my c# code that normally works with other HTML templates:</p>
  <pre><code>using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
              {
                  builder.HtmlBody = SourceReader.ReadToEnd();
              }
  
  string messagebody = string.Format(builder.HtmlBody,
                      //Not important
                      );
  </code></pre>
  <p>Now, this style code in the HTML causes the String.Format to crash (or the bodybuilder, I'm not sure exactly which one has the issue, it fails at string.format).</p>
  <pre><code>&lt;style type=&quot;text/css&quot;&gt;
          #outlook a {
              padding: 0;
          }
  
          .ReadMsgBody {
              width: 100%;
          }
  
          .ExternalClass {
              width: 100%;
          }
  
              .ExternalClass * {
                  line-height: 100%;
              }
  
          body {
              margin: 0;
              padding: 0;
              -webkit-text-size-adjust: 100%;
              -ms-text-size-adjust: 100%;
          }
  
          table, td {
              border-collapse: collapse;
              mso-table-lspace: 0pt;
              mso-table-rspace: 0pt;
          }
  
          img {
              border: 0;
              height: auto;
              line-height: 100%;
              outline: none;
              text-decoration: none;
              -ms-interpolation-mode: bicubic;
          }
  
          p {
              display: block;
              margin: 13px 0;
          }
      &lt;/style&gt;
      &lt;!--[if !mso]&gt;&lt;!--&gt;
      &lt;style type=&quot;text/css&quot;&gt;
          @media only screen and (max-width:480px) {
              @-ms-viewport {
                  width: 320px;
              }
  
              @viewport {
                  width: 320px;
              }
          }
      &lt;/style&gt;
      &lt;style type=&quot;text/css&quot;&gt;
          @media only screen and (min-width:480px) {
              .mj-column-per-100 {
                  width: 100% !important;
              }
  
              .mj-column-per-60 {
                  width: 60% !important;
              }
  
              .mj-column-per-40 {
                  width: 40% !important;
              }
  
              .mj-column-per-50 {
                  width: 50% !important;
              }
          }
      &lt;/style&gt;
      &lt;!--[if mso]&gt;&lt;xml&gt;
              &lt;o:OfficeDocumentSettings&gt;
              &lt;o:AllowPNG/&gt;
              &lt;o:PixelsPerInch&gt;96&lt;/o:PixelsPerInch&gt;
              &lt;/o:OfficeDocumentSettings&gt;&lt;/xml&gt;&lt;![endif]--&gt;
      &lt;!--[if lte mso 11]&gt;&lt;style type=&quot;text/css&quot;&gt;.outlook-group-fix {    width:100% !important;  }&lt;/style&gt;
          &lt;![endif]--&gt;
      &lt;!--[if !mso]&gt;&lt;!--&gt;
      &lt;link href=&quot;https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;
      &lt;link href=&quot;https://fonts.googleapis.com/css?family=Merriweather&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;
      &lt;style type=&quot;text/css&quot;&gt;
          @import url(https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);
          @import url(https://fonts.googleapis.com/css?family=Merriweather);
      &lt;/style&gt;
      &lt;!--&lt;![endif]--&gt;
  </code></pre>
  <p>Any ideas?  I am open to suggestions of how to put this CSS section externally if the reason for the failure is not obvious.</p>