How do I break a line to send an email to a user with HTML?

Asked

Viewed 756 times

0

I send an email to the user who enters the application. I would like to know how I do the line break, so that it stays the way I wish. Below the code I use:

private void newUserEmail(string email, string sexo, string usuario)
        {
            String strResult, strURL;
            string conteudo;
            strURL = "http://app.com.br/email_template/padrao.html";
            WebResponse objResponse;
            WebRequest objRequest = HttpWebRequest.Create(strURL);
            objResponse = objRequest.GetResponse();
            using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
            {
                strResult = sr.ReadToEnd();
                sr.Close();
            }

            string subject = null;
            if (sexo.Equals("F"))
            {
                subject = "Bem Vinda!";
                conteudo = "<b>Bem Vinda!! "+usuario+ "</b>";/*string.Format(" /*string.Format("<b>Bem Vindo, " + usuario + "!<b>{0}" +
                    "<b>Linha 2:{1}" +
                    "1. Linha 3.{2}" +
                    "2. Linha 4.{3}" +
                    "3. Linha 5.{4}", Environment.NewLine);*/
            }
            else
            {
                subject = "Bem Vindo!";
                conteudo = "<b>Bem Vindo! " + usuario+ "</b>";/*string.Format("<b>Bem Vinda, " + usuario + "!<b>{0}" +
                    "<b>Linha 2:{1}" +
                    "1. Linha 3.{2}" +
                    "2. Linha 4.{3}" +
                    "3. Linha 5.{4}", Environment.NewLine);*/
            }

            string html = strResult;

            string body = html.Replace("{{{CONTEUDO}}}", conteudo);
            SendEmail.SendMessage(email, body, subject);
        }

The commented lines were what he had tried to do, but without success. Thank you.

2 answers

4


Only use HTML line break tag <br>.

conteudo = "Linha 1<br>Linha 2<br>Linha 3<br>";

2

Uses the <br> same as html

"<b>Linha 2:{1}<br/>" +
"1. Linha 3.{2}<br/>" +
"2. Linha 4.{3}<br/>" +
"3. Linha 5.{4}", Environment.NewLine);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.