Jump to content
Server Maintenance This Week. ×

sending mail with FMP field text in body


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

Recommended Posts

I need a script to send an email to a person and take, at random, the text out of a specific field in a FMP 8 data base.

I am not good at scripting and so far my attempts have failed.

Does anybody have any ideas?

Here is the mail script I use that works fine to sent fixed text:

set theSubject to "Subject text" --change me

set theBody to "Body text" --change me

set theTarget to "[email protected]" --change me

tell application "Mail"

set newMessage to make new outgoing message with properties {subject:theSubject, content:theBody}

tell newMessage

make new to recipient at end of to recipients with properties {address:theTarget}

set sender to "Me " --change me

end tell

send newMessage

end tell

but not sure how to get to the field in in my data base and select one randomly.

Link to comment
Share on other sites

I want to use my mailing list to send a quote every day from my FMP database. I think this can only be done from the outside of the DB as it contains no email addresses.

so the mail script step would not help.

Link to comment
Share on other sites

fixed that by using:

end tell

tell application "FileMaker Pro Advanced"

	show every record in database "Quotes" -- works	

still not sure how to get it to select a random record and copying it.

BTW, rest of your code does not work either. hangs already on the field/layout selection.

Link to comment
Share on other sites

I am not sure what you're doing. You need to open Scriptmaker and create a new script with the steps I have outlined. In the step Go to Record (or more precisely, Go to Record/Request/Page), specify 'By calculation...', and enter:

Ceiling ( Random * Get (FoundCount) )

into the calculation window.

Link to comment
Share on other sites

yes, I am in Scriptmaker and have made a new script.

Now I understand your instructions and it works. Not sure what I did wrong so far, but never mind, thanks for your patience.

however I need to enter a number and would like it to be automatically and random generated. Is this possible?

Link to comment
Share on other sites

thanks for your help comment,

in case anybody else is following this and interested, here is the Applescript that works, adjust as needed to point to the FMP file and where ever you want to paste it to.

I activated the script in FMP8, by giving it 'CMD 1' as a key command.

So the Applescript triggers the FMP script and takes the copied contents and pastes it, in this case in a new TextEdit document.

tell application "Finder"

activate

open document file "X" of folder "Y" of disk "Z"

tell application "System Events"

tell application "FileMaker Pro Advanced" to activate

keystroke "1" using command down

end tell

end tell

delay 3

try

set the clipboard to Unicode text of (the clipboard as record)

on error errMsg

display dialog errMsg

end try

tell application "TextEdit"

activate

delay 0.5

tell application "System Events"

key code 48 using {command down}

key code 9 using {command down}

end tell

end tell

Link to comment
Share on other sites

Why not simply something like:

tell application "FileMaker Pro Advanced"

open "HD: ... Quotes.fp7"

do script "Random Quote"

set dailyQuote to cellValue of cell "Quote" of current record

end tell

tell application "Another Application"

set some object to dailyQuote

...

I am not sure that's the correct syntax - all I am trying to say that you can address objects directly, instead of trying to emulate mouse clicks and keyboard presses.

Link to comment
Share on other sites

This topic is 5529 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.