0

How do I copy line breaks from a multi line textbox or a rich text field into an email?

Hi all,

I need to be able to sent mass mailings to all relations/clients. For this purpose I have created a form with a text field "subject" and a multi line text field "body".

Upon clicking the send button, an email is sent to all clients. However, the line breaks in the text field body are not being copied to the email. Instead, the email just is one long line of text. 

I have tried generating a variable first with coding for line breaks:

"blablabla"+"

"+"blablabla"

I have tried a rich text field as well as a multi line text field and I am using html tag:

from:

to:

text:" "

html: Body

 

I cannot seem to get it working. Any tips?

Thank you all in advance!

11 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Use a rich text field for the body, place it in a variable using raw() function.

    let Body := raw(richtTextfield);

    ....

    html : Body

    Steven

    • Martijn_Burghoorn
    • 3 yrs ago
    • Reported - view

    Thanks! 

    I learned a new function! :)

    This works for the rich text field indeed. But it solves a part of my problem.

    In the mail I'd like to refer to the records the mail is about. So I have created a variable xText:

     

    Let x : id

    for a in select Clients where File = x do

    let xText := field1+"

    "+Field2+"

    "+Field3

     

    After your post I have tried a dummy rich text field:

    'Dummy Text':= xText

    and then

    Body2:=raw(xText)

     

    In the email the HTML tag is

    html: Body+"<br><br>"+Body2

     

    Body with line breaks now works thanks to you. But Body2 still is just a long string of fields in a record...

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Well, for this there is also a solution: first make in your rich text field a reference where you want the lines to be added, something like this:

    Dear, blablabla

    {reference1}

    {reference2}

    And in the formula of the button where you send the email use the replace function:

    let tempBody := replace(raw(richtextfield),"{reference1}",Field2);

    Let Body := replace(tempBody,"{reference2}",Field3);

    ...

    html: Body

    Note if Field2 or 3 is also a richtextfield you also use the raw() function :

    let tempBody := replace(raw(richtextfield),"{reference1}",raw(Field2));

    Steven

    • Martijn_Burghoorn
    • 3 yrs ago
    • Reported - view

    Thank you once again Steven!

    I guess I am doing something wrong still. Perhaps I am reading your advice not correctly. I now have a text box "subject" and a rich text field "message".

    The rich text field contains the message to be typed by the user, followed by {Reference}, so it looks like

     

    "Blablabla

    blablabla

    blablabla"

    {Reference}

     

    The button then is coded as follows:

    let x := Id;

    for a in select FILES where CLIENTS = x do

    let xText := "FILES CONCERNED: " + "

    " + "File number: " + a.'FILE NUMBER' + "

    “+ “File details: “+a.’FILE DETAILS’+”

    “+”Remarks: “+a.REMARKS

    let Body := replace(raw(MESSAGE), "{Reference}", xText);

    sendEmail({

    from: userEmail(),

    to: userEmail(),

    bcc: array I have previously created

    subject: SUBJECT,

    text: " ",

    html: Body

    })

    end

     

    The result is an e-mail containing the custom text displayed as intented, with the line breaks. But the Files concerned are still one string without the line breaks...

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Try this:

    let x := Id;
    let i := (select FILES where CLIENTS = x);
    let xText := "FILES CONCERNED:" + "
    "+join(for p in range(0, cnt(i)) do
    File number: " + item(i, p).'FILE NUMBER' + "
    "+"File details: " + item(i, p).'FILE DETAILS' + "
    "+"Remarks: " + item(i, p).REMARKS end, "
    ")
    let Body := replace(raw(MESSAGE), "{Reference}", xText);
    sendEmail({
    from: userEmail(),
    to: userEmail(),
    bcc: array I have previously created
    subject: SUBJECT,
    text: " ",
    html: Body
    })
    end

    If the reference text is still not OK, try using raw(xText)

    Good luck and let us know if you need further assistance or if it worked.

    Steven

    • Martijn_Burghoorn
    • 3 yrs ago
    • Reported - view

    Hi Steven,

    Really appreciate all your help and efforts. It doesn't work though. I have tried both xText and raw(xText) and it still shows without line breaks.

    Also, in this code the e-mail for each individual client is now also showing the file info for other clients. That is why I at first created a "for ... in... do"-loop.

    I am trying to achieve:

     

    Email 1 for client 1:

    Dear mr/ms "client name 1",

    "blablabla

    blablablabla"

     

    Files concerced:

    File number: File 1

    File details: Details 1

     

    File number: File 3

    File details: Details 3

     

    and then for another client:

    Dear mr/ms "client name 2",

    "blablabla

    blablablabla"

     

    Files concerced:

    File number: File 2

    File details: Details 2

     

    File number: File 5

    File details: Details 5

     

    etc. etc.

     

    I am starting to think it is just not possible to create such a list in an e-mail without restructuring my whole application...

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Can you try this in a formula field and see what it gives?

    let x := Id;
    let i := (select FILES where CLIENTS = x);
    "FILES CONCERNED:" + "
    "+join(for p in range(0, cnt(i)) do
    File number: " + item(i, p).'FILE NUMBER' + "
    "+"File details: " + item(i, p).'FILE DETAILS' + "
    "+"Remarks: " + item(i, p).REMARKS end, "
    ")

     

    or replace let x := Id by let x := this;

    or we must implement the html tags <br> in our xText-variable

    or you may invite me to your Ninox team and have a look together in a zoom session.

    Steven

    • Martijn_Burghoorn
    • 3 yrs ago
    • Reported - view

    Hi Steven,

    Again; really appreciating your help! Thanks a lot.

     

    The formula field returns the requested info with line breaks. So that is working. However, it still returns all file info for all files and not per specific client.

     

    P.s. I cannot invite you to my team, as I currecntly only have a 1-user subscription

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Martijn,

    Normally this is not a problem because I myself also have a Ninox account and this has no effect on you. But I can understand that for privacy reasons this is not desired.

    Can you post your data model to get an overview of your database structure to have some more insight?
    I'm willing to help you, so you may email me also. (Even in Dutch) You can find my details in the Partners section.

    Steven

    • Martijn_Burghoorn
    • 3 yrs ago
    • Reported - view

    Ha Steven, 

    Ik had niet door dat je partner en Belgisch bent! :)

    Bedankt voor al je hulp! Ik moet deze applicatie (in ieder geval een demo versie) draaiend hebben in januari en verlies nu teveel tijd aan dit (laten we eerlijk zijn:) kleine lay-out probleem. Het is gewoon irritant dat het niet eruit komt te zien zoals je graag wilt, maar heb het voor nu opgelost met de info op 1 regel, gescheiden door leestekens. Niet zo mooi, maar het brengt de info over, die nodig is en verfraaien kan dan altijd nog later.

    Ik zal je dan ook graag begin volgend jaar nog eens om advies vragen, mocht ik het nog niet hebben kunnen vinden.

    Hartelijke groet!

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Ok, bedankt Martijn, mail me gerust als het nodig is. Groeten uit België.

Content aside

  • 3 yrs agoLast active
  • 11Replies
  • 958Views
  • 1 Following