Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

sending mail with FMP field text in body

Featured Replies

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.

Why don't you use send mail script step? As I remember, it was added with version 7.

  • Author

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.

How about something like:

Go to Layout [ Quotes ]

Show All records

Go to Record [ Ceiling ( Random * Get (FoundCount) ) ]

Perform AppleScript

  • Author

I tried this, but it hangs on

'Show All records' last word

not sure how to fix.

  • Author

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.

What I suggested is a Filemaker script.

  • Author

oops did not realise.

Go to Record [ Ceiling ( Random * Get (FoundCount) ) ]

does not work.

Get: Specified field table can not be found

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.

  • Author

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?

The script selects a random record from all the records in the table. I am not sure why you would need to enter a number for this.

  • Author

it does though, have a look:

http://www.imageno.com/zis10bi647x3pic.html

Select the option "Perform without dialog' for the Go to Record/Request/Page step.

  • Author

ah, of course! thanks a million!!!!

I now need to see if I can build a Applescript around this.

You could have the Filemaker script run your Applescript as its final step. If you want to run this from "outside", have your Applescript call the FM script, then proceed with the data from the current record.

  • Author

Thanks that was what I was planning to do, will experiment later when I am back on the machine that has the DB

  • Author

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

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.

  • Author

cool works too! only problem is it puts the quote in quotation (") marks.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.