AnsweredAssumed Answered

Losing Text Returns When Using Applescript Email Import

Question asked by avah12 on Feb 12, 2010
Latest reply on Feb 12, 2010 by FentonJones

Title

Losing Text Returns When Using Applescript Email Import

Post

I have a script that I use to import emails from Apple Mail to Filemaker.  Everything works as I'd like, except for the email body.  When it imports the body data it loses any style and text returns that the original had.  I'm fine with losing color, bolding, etc, but I would like for the returns to stay, otherwise it makes the email text hard to read.

 

What's odd is that after it has been imported, if I copy the text out of the field and into another program like Stickies, the text returns are intact.  Anybody have advice?  Any help would be appreciated.  I am using Filemaker 9 on OS X Leopard.

 

The following is the AppleScript that I'm using.

 

tell application "Mail"

set selectedMessages to selection

set selectionCount to (count of selectedMessages)

repeat with messageNumber from 1 to selectionCount

set theMessage to item messageNumber of selectedMessages

set selectionCount to (count of selectedMessages)

set emailbody to content of theMessage

set emailsender to sender of theMessage

set emailsubject to subject of theMessage

set emaildate to date received of theMessage as string

 

tell application "FileMaker Pro"

set cell "gEmailFrom" of current record to emailsender

set cell "gEmailSubject" of current record to emailsubject

set cell "gEmailMessageBody" of current record to emailbody

set cell "gEmailRawDateInput" of current record to emaildate

end tell

end repeat

end tell 

Outcomes