On Apr 28, 2008, at 6:11 PM, Joe wrote:
AppleScripts run from within FileMaker don't need the "tell
FileMaker, end tell" lines. FileMaker assumes everything is is
directed at it unless otherwise specified.
This is certainly true. But the trouble in this case is that the
"tell FileMaker" block is inside the "tell Eudora" block. To be able
to remove (or comment out) the FileMaker block you need to pull it
out into a subroutine. Here is much the same with a subroutine. I
changed a couple of things. I set a "rec" reference to the new
record, and used that to set the fields (I don't know if it's
better). And I changed the names of the FileMaker fields, simply
because I wanted to test in a FileMaker file. I'm lazy about typing :-]
tell application "Eudora"
set theMailbox to "In"
set numMessages to count every message of mailbox theMailbox
repeat with msgNum from 1 to numMessages
set msg1 to (a reference to message msgNum of mailbox
theMailbox)
set address to field "From" of msg1
set aa to the offset of "<" in address
if (aa ≠ 0) then
set az to the offset of ">" in address
if (az ≠ 0) then set address to text (aa + 1) thru (az - 1) of
address
else
set aa to offset of ":" in address
set az to (offset of "(" in address) - 1
if az = 0 then set az to length of address
set address to text from (aa + 1) to az of address
end if
set iName to sender of msg1
set iSubject to subject of msg1
set iDate to message date of msg1
set iEmail to address
set iBody to field "" of msg1
my FM_record(iName, iSubject, iDate, iEmail, iBody)
log numMessages - msgNum
end repeat
end tell
on FM_record(iName, iSubject, iDate, iEmail, iBody)
--tell application "FileMaker Pro Advanced"
set rec to create new record at table "Emails" of database
"EudoraMails"
set data of cell "Name" of rec to iName
set data of cell "Subject" of rec to iSubject
set data of cell "Date_" of rec to iDate
set data of cell "Email" of rec to iEmail
set data of cell "Comment" of rec to iBody
save record
--end tell
end FM_record