Send email with carriage return

Discussion in 'ASP .Net' started by =?Utf-8?B?TWlrZQ==?=, Sep 4, 2007.

  1. 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
    =?Utf-8?B?TWlrZQ==?=, Sep 4, 2007
    #1
    1. Advertising

  2. "Mike" <> wrote in message
    news:...

    > 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
    Mark Rae [MVP], Sep 4, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ferdi
    Replies:
    5
    Views:
    4,681
    Jacob Yang [MSFT]
    Aug 24, 2003
  2. Xeno Campanoli
    Replies:
    0
    Views:
    227
    Xeno Campanoli
    Feb 13, 2006
  3. TJO

    Carriage Return Email Body

    TJO, Nov 22, 2004, in forum: Javascript
    Replies:
    16
    Views:
    447
  4. Steve Anderson
    Replies:
    3
    Views:
    249
    Steve Anderson
    Jun 21, 2004
  5. 280SEL

    Send Carriage return

    280SEL, Sep 17, 2007, in forum: Perl Misc
    Replies:
    1
    Views:
    87
    Mumia W.
    Sep 17, 2007
Loading...

Share This Page