Microsoft Outlook AppleScript Question

I have a simple question that I cannot figure out. What I want to do is to put line breaks in a variable and then use as body in an Outlook email the AppleScript creates.

According to all AppleScript reference material I found on the Internet, the following should work:

set cnt to linefeed & "Approved" & linefeed & linefeed & "Thanks"
return cnt -- this works and displays the linefeeds as follows:

Approved

Thanks

However, when I use it to create the body of the email, it just sets it as:
Approved Thanks

I tried many things, including:

  • used "\n" or "\r" instead of linefeed
  • created the string in a variable in KM and passed it to AppleScript

None of the tries worked. It must be something with the Outlook AppleScript command.

Full script:

Result:

Thank you in advance.

Alex

Hi, Alex

Ooh, I hadn't thought to look at Outlook's AppleScript dictionary. This looks really helpful :slight_smile:

I wonder if it's sending HTML by default (is that the way you've got Outlook set up in its Composing preference)? That would explain the lack of line feeds. Could you try...?

  • Setting the message content using 'plain text content' instead of 'content' (probably easier for testing)?
  • Using HTML markup?

Best wishes,
Steve

Steve, thank you. That must be it. I would like to keep the body of the message HTML How would one convert text with line breaks to HTML?

Alex

OK. Got it all solved! Thank you very much. I used this website to get the HTML code. (You have to check the "Use line break tags only" option.

Alex

If you're composing all of the body text, then just write it with HTML markup (which is beyond the scope of what I can offer here - the Internet is your friend!).

Depending on who you're sending the email to, you may wish to include a plain text equivalent, too (with that 'plain text content' option, I'm guessing), complete with actual line-breaks.

If you just want to convert some line breaks into ones which will display in HTML, then (at its most basic) use either paragraph <p> ... </p> tags or just a <br> tag - using a regex substitution:

Test HTML encoding.kmmacros (2.1 KB)

Best wishes,
Steve