Sending mail via SMTP Server

TatevikTatevik Member Posts: 28
Hello All!!! I need help with following issue :? :? :?
I used to send mail via SMTP server by using Dynamics NAV 5.0 SP1 standard 400 codeunit.
I need to add several lines to the body.

When I wrote the following part of th code in the loop it didn't return carriage return and all information was shown on the one line.
SMTPMail.AppendBody(Body +FORMAT(chCR) + FORMAT(chLF));

Then I change code and instead of FORMAT(chCR) + FORMAT(chLF)
I used <p> or <br> (HTML tags).
somthing like this:
SMTPMail.AppendBody(Body +'<p>')
by these way everything was fine each feild was typed from new line.

Any suggestion. why 'FORMAT(chCR) + FORMAT(chLF)' does not work?

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    If mail is send using HTML, then CR/LF do not work.

    If for example you write:
    Line 1

    Line 2
    in the body of a HTML-formatted mail, it will appear as
    Line1Line2
    If the mail is send as text, then CR/LF will work as intended.

    In codeunit 400, the parameter HtmlFormatted in function CreateMessage is used to determine if the mail is send out as HTML or as text.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • MIMI Member Posts: 20
    Hi Tatevik,

    I created a text variable CRLF and set CRLF[1] := 13; and CRLF[2] := 10;
    When I add at the end of my SMTP.AppendBody('<Your Text>' + CRLF + CRLF ) I'm getting an additional line after my text.

    I hope this helps.


    ...Manfred
  • MallikarjunaMallikarjuna Member Posts: 64
    Thank You Luc...

    It helped me so much. :)

    Thanks Again,
    Mallikarjuna
Sign In or Register to comment.