you can't send multiple attachments in one email if that is what you're trying to do.
Not sure that you're use of the GetAsText() function works with the way container storage changed in FM12.
I usually set a file path, like:
"file:" & get(temporarypath) & "attachment.pdf"
and use the export field contents script step to dump the attachment to a temporary location.
Then the same variable I use to export I use as the attachment. Has always worked in 12/13 without issue, with the note that it only supports one attachment.
Plugins allow you to send multiple attachments if that is needed.
Mike is quite right. GetAsText ( ) will give you a lot more data than just a file name, unless it is stored within the field—ie. using storing a reference only, or any external storage setting. Therefore you willl need to parse out the name of the attachment. In FM13 you can use the GetContainerAttribute ( ) function as follows:
GetContainerAttribute ( <yourfieldnamehere> ; "filename" )
I may have not mad it clear. Im not sending multible attachments I send one PDF per e-mail. When I bring the PDF into FM I bring it in not just referance. So It should create an e-mail, attach the PDF and send it out. It works perfict in FM 11 When I upgrade the database to 12 it stopped attaching the file.
You can not attached the contents of a container field to an email. You need to export the file from the container. I don't see an Export Field Contents script step in your script. To attach the file to the email, you then need to specify the path to the exported file.
This is a real bummer. It could be done in FM11. I wander why they would break that. Its not worth the re-write right now so I will jsut keep FM 11 around.
If the script worked in 11 it should work in 12. You might have a bad file reference. Without an export field contents script step, you script should not work in Fm 11. Can you show the complete send mail script step?
I stand corrected by rgordon. Your script needs an ExportFieldContents step, eg:
Set Variable [ $$attachment; GetAsText ( <yourContainerField> ]
Export Field Contents [ yourTableName::yourContainerField; “$$attachment” ]
Send Mail [ yourChosenSettings ; Attachment: “$$attachment” ]
Set Variable [ $$attachment; Value:"" ]
NOTE: The above will work just as well if you use a local variable ( single dollar sign – $attachment ). Then you can do away with the last step above, as the variable nae will not persist once the script completes.
I'm fairly certain your script worked in FM 11 because you either stored the PDF as a reference to the file (which you stated that you did not do) or the original PDF was in the same folder as the filemaker file. The script will not work if the PDF is stored in the container (not a reference) and the original PDF is not in the same folder as the FileMaker file. The script should still work in FM 12 if the above conditions are met.
For my own interest I played around with this issue and attach a demo file which achieves CarlEarl's purpose—WITHOUT an ExportFieldContents step, I might add, contrary to advice by rgordon and a previous post of mine.
The email script is configured to work in both FM12 and FM13, in all the following cases: (1) no storage settings, file stored in field; (2) no storage settings, file stored as reference only ; (3) storage set to external(secure) ; (4) storage set as in 3 above, but overidden with file stored as reference.
It all tested OK on my system, so I attach the file for anyone interested.
CarlEarl: I trust this encourages you to persist with your original plan to upgrade to FM12/13!
I tested the file and it worked but if I renamed the original file or deleted the original file, the script no longer worked. The email could not find the attachment. It looks like the script is attaching the original file, not the file in the container field.
Thanks guys. I did some testing and even though I did not have the reference only checked, it seems thats what FM 11 was only refering to the PDF. If I moved the database after I imported the PDF it lost it. That told me it was only storing the reference after all.
I have upgraded the DB and added the export you recomended and it does work fine. Thanks for your help.
You say: "… added the export you recomended …"
I hope you took note of my May 30 post and the attached file which showed that an export step is not really needed.