Send email with carriage return

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,



I'm using the following code to send an email and it's working OK but using
\r\n is not breaking up the lines and I tried Convert.ToChar(10) also and
still it doesn't carriage retun.

MailMessage objMailMsg = new MailMessage(strFrom, strTo);

objMailMsg.BodyEncoding = Encoding.UTF8;

objMailMsg.Subject = strSubject;

objMailMsg.Body = "This the first line \r\n and this is the second line";

if (Session["PDF_Path"] != null)

{

Attachment at = new Attachment(Server.MapPath(AttachmentPath));

objMailMsg.Attachments.Add(at);

}

objMailMsg.Priority = MailPriority.High;

objMailMsg.IsBodyHtml = true;

SmtpClient objSMTPClient = new SmtpClient();

objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

objSMTPClient.Send(objMailMsg);
 
I'm using the following code to send an email and it's working OK but
using
\r\n is not breaking up the lines and I tried Convert.ToChar(10) also and
still it doesn't carriage retun.
objMailMsg.IsBodyHtml = true;

That's because you're using HTML format - \r\n means nothing to HTML...
objMailMsg.Body = "This the first line \r\n and this is the second line";

objMailMsg.Body = "This the first line<br />and this is the second line";
 
Back
Top