jimrecht Posted February 21, 2008 Posted February 21, 2008 I found a nice way to send an email of a text-based record: Set Variable ($email, "mailto:"& YourTable::Username& "<"&YourTable::email_address&">?Subject="&YourTabl e::EmailSubjectField&"&Body="&YourTable::Field_A&" ¶"&YourTable::Field_ Open URL [$email, no dialog] But this only sends the content of one record. Is there any way to send the content of several records, in the body of a single email?
Fitch Posted February 21, 2008 Posted February 21, 2008 You'll need to be more specific about which "several records" you want, but yes, you can use GetNthRecord and/or a looping script to assemble the contents of many records into a variable that you can use for the body. Some browsers (e.g. IE) have limits on URL length. Any particular reason you're not using the Send Mail script step instead of Open URL?
jimrecht Posted February 21, 2008 Author Posted February 21, 2008 Thanks for your quick reply, Tom. I want to avoid using the Send Mail script, because we generally use Google Gmail directly from our web browsers. So here's my situation: I have layout named ClientCalls that contains a portal to a table of our clients' logged phone calls. The Calls table contains the following fields: Calls::ClientName; Calls::CallDate; Calls::CallContent. I want to launch a script (perhaps from a cute little button), from the ClientCalls layout, that will send a single email whose body contains a list of all calls currently showing in the portal, one call per line (each line formatted something like "ClientName/CallDate/CallContent"). Can you guide me as to how I would construct a looping script (or a script with GetNthRecord) to assemble this? Yours, Jim Recht
Fitch Posted February 21, 2008 Posted February 21, 2008 We could just loop through the portal rows, like this: Loop Go to Portal Row (Next, exit after last) End Loop It's faster though to do it with the GetNthRecord function, but this means we won't have an "exit after last option." But that's OK, we can just figure out how many rows are in the portal and construct our exit strategy around that: Set Variable($newline ; "%0D%0A" ) // URL can't have carriage returns, so use this Set Variable($rows ; Count(Calls::CallDate) // be sure to use a field that always has data Set Variable($i ; 1) // this is our counter Loop Set Variable($name ; GetNthRecord(Calls::ClientName ; $i) Set Variable($date ; GetAsDate(GetNthRecord(Calls::CallDate ; $i)) Set Variable($content ; GetNthRecord(Calls::CallContent ; $i) Set Variable($body; $body & $name & "/" & $date & "/" & $content & $newline) Set Variable($i ; $i+1) Exit Loop If($i > $rows) End Loop In your URL you can now use $body instead of YourTable::Field_A.
jimrecht Posted February 21, 2008 Author Posted February 21, 2008 Thanks again Tom. Two more quick questions: 1) Would I write the script like this: Set Variable($newline ; "%0D%0A" ) // URL can't have carriage returns, so use this Set Variable($rows ; Count(Calls::CallDate) // be sure to use a field that always has data Set Variable($i ; 1) // this is our counter Loop Set Variable($name ; GetNthRecord(Calls::Clien tName ; $i) Set Variable($date ; GetAsDate(GetNthRecord(Ca lls::CallDate ; $i)) Set Variable($content ; GetNthRecord(Calls::CallC ontent ; $i) Set Variable($body; $body & $name & "/" & $date & "/" & $content & $newline) Set Variable($i ; $i+1) Exit Loop If($i > $rows) End Loop Set variable ($email, "mailto:"& YourTable::Username& "<"&YourTable::email_address&">?Subject="&YourTabl e::EmailSubjectField&"&Body="&$Body Open URL ($email, no dialog) ?? 2) Is it legal to define a variable like $i (1) and then re-define it ($i + 1), in the same script? Yours, Jim Recht
Fitch Posted February 22, 2008 Posted February 22, 2008 1) Looks right. 2) Yes, notice how we did the same thing with $body, defining it as ($body & etc.) It's really helpful to use FileMaker Advanced so you can use the Data Viewer to watch the values of variables and fields while stepping through a script.
Recommended Posts
This topic is 6119 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 accountSign in
Already have an account? Sign in here.
Sign In Now