It sounds like you've got two requirements:
1) send an email to each user
2) attach a PDF file to each user
a wireframe of a script to do that would look something like this:
Go To Record - First
Set Variable [ $path ; "file:" & get(temporarypath) & "checklist.pdf" ]
go to layout [ PDF layout ]
Save Records as PDF [ $path ; current record ]
go to layout [ original layout ]
send mail [ set email, subject, and use $path as attachment ]
go to record [next]
exit loop if [ get(recordnumber) = get(foundcount) or get(recordnumber) = 25 ]
I would recommend against looping an email send though. Sending emails in a loop is a fast track to getting your email sent straight to spam and your mail server blacklisted. I underlined a check that I added that will stop at 25 emails. That would be an option to add to protect against malicious sending.
Basically you need to get the send mail working for one record first, then just loop that for your found set.
Thanks Mike – we will give this a go.
Administration Officer for Program 5: Adaptive Social and Economic Systems
Personal Assistant to Dr Craig James, Research Program Director
CSIRO Land & Water
GPO Box 1700, Canberra ACT 2601
The information contained in this email may be confidential or privileged. Any unauthorised use or disclosure is prohibited. If you have received this email in error, please delete it immediately and notify the sender by return email. Thank you. To the extent permitted by law, CSIRO does not represent, warrant and/or guarantee that the integrity of this communication has been maintained or that the communication is free of errors, virus, interception or interference.
don't forget to delete your signature when replying via email unless you wanted to share your contact info here.
Thanks for the tip.
Just to piggyback on Lyndas post as I am trying to achieve a similar goal. I have some questions regarding your script.
For the send mail options, what is put into the 'to' box for who to send to. Or does the script work this out? Also for the 3rd line, does that create a path and then name the file checklist.pdf when it is saved in line 5? Will the name of the file be changed for each iteration of the loop? e.g. checklist(1).pdf or am I misunderstanding it(more than likely).
You use the email address from the record you're on. This is a calculation dialog so it could be as simple as:
or using a variable you set earlier:
or even calculated by a case statement for different conditions:
Not IsEmpty( table::email2 ) ; table::email2 ;
Not IsEmpty( table::email3 ) ; table::email3 ;
You are correct in your thoughts about the PDF path. It will overwrite the previous PDF, not give it a new file name, UNLESS you are using this on FileMaker Go, in which case you'll want to add something to make each file unique, EG:
Set Variable [ $path ; "file:" & Get(TemporaryPath) & table::serialNumber & "_checklist.pdf" ]
So if say one person has 5 items assigned to them, will this script send an email saying, person A you have these 5 items, or will it send 5 emails, person A you have item 1, " " item 2, "" etc.
Thanks again for the help
If you want to send 5 emails to a single record, with a different attachment for each, then you would do a loop inside of a loop. The outer loop to go through people, and the inner loop to send each email.
Or better yet, just use an email plugin that supports multiple attachments at the same time.
I'm looking to group records by person. If one person has 5 items they get an email with a list of what they have been allocated. And then it runs through each person and stops. It is basically your script but with some sort function in it?
I'm guessing at find matching records then constrain found set? But how do I say I want to constrain the found set = the name of the current person.
Im sorry if that is confusing, im having trouble thinking this all out
I don't think you're on the right thread here. It sounds like you just need to include a calculation using the List() function to list related items in the content of your email.
That has nothing to do with sending multiple emails to one person or sending multiple emails in a loop.
A quick example of a calculated message related data, sent from your "people" table, would be something like:
"Dear: " & People::FirstName & ",
Here is your list:
" & List ( Items::ItemName)
Brilliant, just what I was looking for.
Since I already have a script set up to send the emails one at a time when triggered, I assume that I could just insert PERFORM SCRIPT inside the Loop?
The steps I have would be: Find the records I want to send to, then send the email.
The script I have is:
Do I need to change this in any way?