locked
Email RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have written the below code , but all the text appears in 1 line.

    using (MailMessage mail = new MailMessage())
    {
    mail.From = new MailAddress(emailFrom);
    mail.To.Add(emailTo);
    mail.Subject = subject;
    mail.Body = "\n\n" + "Dear Sir/Madam";
    mail.Body += "\n\n" + "ID : " + "\n" + Request.QueryString["id"].ToString();
    mail.Body += "\n\n" + "Name : " + "\n" + txtname.Text;
    mail.Body += "\n\n" + "Regards" + "\n";
    mail.IsBodyHtml = true;
    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
    {
    smtp.Credentials = new NetworkCredential(emailFrom, password);
    smtp.EnableSsl = enableSSL;
    smtp.Send(mail);
    }
    }

    Thanks

    Saturday, June 23, 2018 5:12 PM

Answers

  • User-1171043462 posted

    You are not sending HTML. Still you have set mail.IsBodyHtml = true;

    So simply set it to false. And your email will display text in format you want.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 23, 2018 7:25 PM