Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Send email with carriage return

Reply
Thread Tools

Send email with carriage return

 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      09-04-2007
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);

--
Regards,
M.Rochdi
 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      09-04-2007
"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

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


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send Carriage return 280SEL Perl Misc 1 09-17-2007 02:26 AM
Carriage Return added during return of large string from class method Xeno Campanoli Ruby 0 02-13-2006 08:39 PM
Carriage Return Email Body TJO Javascript 16 12-31-2004 01:02 PM
Help: Delete a single carriage return in a file, but not a double carriage return? Steve Anderson Perl Misc 3 06-21-2004 12:48 AM
Postback after carriage return input Ferdi ASP .Net 5 08-24-2003 07:12 AM



Advertisments