Send email with carriage return

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);
 
M

Mark Rae [MVP]

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";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top