Jump to content

Filemaker stripping text formatting


This topic is 6440 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hi, I have a script which attempts to grab the content of an email message from Apple Mail and insert it into a text field.

The problem is that Filemaker strips out all the carriage returns and paragraph breaks etc from the email contents, resulting in one big unreadable lump of text.

Copying/pasting from Apple Mail into the field does preserve the formatting.

Does anyone know of a technique to preserve this information?

Link to comment
Share on other sites

  • Newbies

Thanks for the response, unfortunately no change.

I have worked around the issue by writing the content of the email to a file, stripping carriage returns, converting tabs to spaces and then importing the resulting file into Filemaker.

But if anyone has an easier method, I'd still be interested.

Link to comment
Share on other sites

The problem is that what you get from mail.app carries a ASCII 10 as carriage return (rather linefeed) but filemaker only recognizes ASCII 13 as such.

You can do it this way:

tell application "Mail"

	set mycontent to content of message 100 of mailbox 4 as styled text

end tell

set AppleScript's text item delimiters to (ASCII character 10)

set myVar to text items of mycontent

set AppleScript's text item delimiters to (ASCII character 13)

tell application "FileMaker Pro Advanced"

	set cell 1 to myVar as string

end tell

...in a similar way do you have to question for the tabs by asking:

nn contains (ASCII character mm)

...to get esatblished what the tab is and substitute it with 29 as FM recognizes.

--sd

Link to comment
Share on other sites

I'd just add that tab is (ASCII character 9), but you can also just write tab.

tell application "Mail"

set mycontent to content of message 1 of mailbox 1 as styled text

end tell

set AppleScript's text item delimiters to (ASCII character 10)

set myVar to text items of mycontent

set AppleScript's text item delimiters to (ASCII character 13)

set AppleScript's text item delimiters to tab

set newVar to text items of myVar

set AppleScript's text item delimiters to (ASCII character 29)

tell application "FileMaker Pro Advanced"

set cell 1 to newVar as string

end tell

Edited by Guest
tab is 9, not 10
Link to comment
Share on other sites

I came to think of something Bruce showed us:

tell application "Mail"

       set mycontent to content of message 100 of mailbox 4 as styled text

end tell

set shellstuff to " tr 'n' 'r' "

do shell script "echo " & quoted form of (mycontent) & shellstuff

tell application "FileMaker Pro Advanced"

	copy result to cell 1

end tell

But I wonder once more how the 't' should be handled in a similar way piped into the next section???

--sd

Link to comment
Share on other sites

I don't know that you really need to do the tr. I think just echo does it. Try this:

tell application "Mail"

set mycontent to content of message 1 of mailbox 1 as styled text

end tell

do shell script "echo " & quoted form of (mycontent)

tell application "FileMaker Pro Advanced"

copy result to cell 1

end tell

Link to comment
Share on other sites

  • Newbies

Thanks Fenton and Soryn,

I tried the last suggestion of just echoing the quoted form and it has worked, so since that's the simplest, that's what I'll go with.

But it was interesting to learn of the tr function, I may be able to use that in some other stuff.

So it's all good.

Thanks again.

Link to comment
Share on other sites

  • 8 months later...

This topic is 6440 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.