locked
Generate Outlook Email With ASP RRS feed

  • Question

  • User974100899 posted

    I am attempting to use C# to generate an outlook template, but my issue is that I have " quotes in the HTML code.  Even if I change the " quotes to ' quotes I still get errors.  What would be the correct way to set this up?

    string bodyofEmail = "<span>Just Reply:</span></p>
    <ol style="margin-top: 0px;">
    <li>XXX </li>
    <li>YYY </li>
    </ol>
    <p><strong>ONE IMPORTANT NOTE</strong>, any change made ......<br /><br />
    <span style="background-color: #ffff00;">Ignore from here down.</span>That info is:<br /> <a href="http://xxyyzz.jsp">http://xxyyzz.jsp</a><br>Thanks!<br /><br /></p>"

    Sunday, May 13, 2018 4:48 PM

Answers

  • User-369506445 posted

    hi

    here are two way for put double quote in string

    first use @ before it and use two double quote below like :

    string bodyofEmail = @"<span>Just Reply:</span></p>
    <ol style=""margin-top: 0px;"">
    <li>XXX </li>
    <li>YYY </li>
    </ol>
    <p><strong>ONE IMPORTANT NOTE</strong>, any change made ......<br /><br />
    <span style=""background-color: #ffff00;"">Ignore from here down.</span>That info is:<br /> <a href=""http://xxyyzz.jsp"">http://xxyyzz.jsp</a><br>Thanks!<br /><br /></p>";
    

    second you can use \ before each double quote below like :

    string bodyofEmail = "my name is \"vahid\"";

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 13, 2018 5:30 PM

All replies

  • User-369506445 posted

    hi

    here are two way for put double quote in string

    first use @ before it and use two double quote below like :

    string bodyofEmail = @"<span>Just Reply:</span></p>
    <ol style=""margin-top: 0px;"">
    <li>XXX </li>
    <li>YYY </li>
    </ol>
    <p><strong>ONE IMPORTANT NOTE</strong>, any change made ......<br /><br />
    <span style=""background-color: #ffff00;"">Ignore from here down.</span>That info is:<br /> <a href=""http://xxyyzz.jsp"">http://xxyyzz.jsp</a><br>Thanks!<br /><br /></p>";
    

    second you can use \ before each double quote below like :

    string bodyofEmail = "my name is \"vahid\"";

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 13, 2018 5:30 PM
  • User753101303 posted

    Hi,

    Seems you are looking for the "verbatim" string syntax:

    string bodyofEmail = @"<span>Just Reply:</span></p>
    <ol style=""margin-top: 0px;"">
    <li>XXX </li>
    <li>YYY </li>
    </ol>
    <p><strong>ONE IMPORTANT NOTE</strong>, any change made ......<br /><br />
    <span style=""background-color: #ffff00;"">Ignore from here down.</span>That info is:<br /> <a href=""http://xxyyzz.jsp"">http://xxyyzz.jsp</a><br>Thanks!<br /><br /></p>";

    See https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/verbatim paragraph 2 for details

    Sunday, May 13, 2018 5:34 PM