View Single Post
  #7  
Old May 13th, 2008, 07:20 PM
barhar barhar is offline
Registered User
 
Join Date: May 2005
Posts: 1,339
Thanks: 0
Thanked 1 Time in 1 Post
barhar is on a distinguished road
Based on the information you provided. replace ...

set fName to "HD02_232.03_007:Users:barhar:Desktop:Untitled.fp7" -- Full path to 'FileMaker Pro' database file.

... with ...

set fName to "smb://workgroup;username:password@192.168.0.103/Applicants" -- Or similar; where 'username' and 'password' are supplied by you.

... or similar. I have no experience or idea about 'fmnet:/...'.

'"Can't make item 1 of {} into type string"' - yes. Attempting to obtain an expected item from an empty list should result with an AppleScript error; unless - if 'try' ... 'end try' are used.

There is zero error checking in the provided code.

Final code (with some checking of the size of the lists) is provided below:

-- Code starts here --

set fName to "smb://workgroup;username:password@192.168.0.103/Applicants" -- Or similar, where 'username' and 'password' are supplied by you.

property firstNameCell : "First_Name" -- Name of 'First Name' assigned cell.
property eMailAddressCell : "eMail_Address" -- Name of 'e-mail Address' assigned cell.

property eM_Salutation : "Hello"
property eM_Subject : "Your subject here"
property eM_Contents : "Your e-Mail message content here"

tell application "FileMaker Pro Advanced 8.5"
activate

open file fName -- Open database file.
set {firstNames, eMailAddresses} to {(every cell of document 1 whose name is firstNameCell), (every cell of document 1 whose name is eMailAddressCell)}

-- quit -- Optional.
end tell

set eMailAddressesCount to count eMailAddresses -- Obtain number of items of 'eMailAddresses' list.
if ((eMailAddressesCount > 0) and ((count firstNames) = eMailAddressesCount)) then -- Lists must be equal in items, and greater than 0.
tell application "Mail"
activate

repeat with i from 1 to (count eMailAddresses)
set nMessage to make new outgoing message with properties {visible:false, subject:eM_Subject, content:(eM_Salutation & " " & (item i of firstNames) & "," & return & return & eM_Contents)}
tell nMessage
make new to recipient at end of to recipients with properties {address:(item i of eMailAddresses)}
--send
say "Sent"
end tell
end repeat

-- quit -- Optional.
end tell
else -- This line, and the next four (4) lines, are optional.
set errorMessage to "An error occurred"
activate
say errorMessage
display dialog errorMessage buttons {"OK"} default button 1 giving up after 5
end if

-- Code ends here --

Last edited by barhar; May 14th, 2008 at 06:38 AM.
Reply With Quote