Newbies Pstrecker Posted January 8, 2006 Newbies Posted January 8, 2006 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?
LaRetta Posted January 8, 2006 Posted January 8, 2006 I do not know Apple Mail. But when the paste wonks out for me on Windows (in a text field), I sometimes have better luck pasting into a container.
Newbies Pstrecker Posted January 8, 2006 Author Newbies Posted January 8, 2006 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.
Søren Dyhr Posted January 8, 2006 Posted January 8, 2006 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
Fenton Posted January 8, 2006 Posted January 8, 2006 (edited) 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 January 8, 2006 by Guest tab is 9, not 10
Søren Dyhr Posted January 8, 2006 Posted January 8, 2006 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
Fenton Posted January 8, 2006 Posted January 8, 2006 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
Newbies Pstrecker Posted January 9, 2006 Author Newbies Posted January 9, 2006 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.
Joost Miltenburg Posted September 29, 2006 Posted September 29, 2006 Hi, This was also a lot of help to me ! Thnx ! But what about contents that has both text and pictures in the body (like company logo's) Every picture gives me a '?' i don't quite care about pictures, but would like to get the remaining text in the body. TIA
Recommended Posts
This topic is 6629 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 accountSign in
Already have an account? Sign in here.
Sign In Now