Page 1 of 1

Attach file in mailing template?

PostPosted: Tue Jan 29, 2008 5:23 pm
by macfreq
What is the attach file field used for in the mailing template? I would like to use this to mail a PDF of a customer's invoice as an attachment. Can this be used somehow to do this? I want to create a template for sending the attached invoice, but the attachment will change for each mailing.
If I create a script to create the PDF and use the mail script step to attach it, where do you suggest I save the temporary PDF file, for a PC and Mac?

Thanks.

PostPosted: Tue Jan 29, 2008 7:35 pm
by John Sindelar
That is exactly what the attached file in Mailings is for. But if you just want to script the emailing of a PDF of your invoice, then you don't need to use our mailing component, which is more about sending a merged mail (with the same attachment) to a group of contacts.

You can do all this right in your print invoice script. Edit the beginning of your print script by defining the name and location of the file you want to print. Something like:

Set Variable [ $Path ; "file:" & Get ( DesktopPath ) & "YourInvoice" & ".pdf" ]

You can replace "YourInvoice" with the customer's name, your invoice number, or whatever you need. Then in your Save Records as PDF script step (where you make the pdf) simply use $Path in the specify output file option. Then when you send the email, in your Send Mail script step, use $Path again in the Specify option to the right of "Attach file".

Note that if you name each PDF separately, you'll end up with a bunch of these on your desktop. You you might want something like Get ( FileMakerPath ) & "Invoices/YourInvoice" providing you've created a folder called invoices inside your FileMaker Pro 9.0 folder.

Hope that helps.

PostPosted: Wed Jan 30, 2008 12:10 am
by macfreq
Thanks John, that was the answer I was looking for. I'm going to modify the Print script like you said and use the Get (TemporaryPath) to save the PDF temporarily before I attach it and send it with the send email script step.

Thanks again.

PostPosted: Wed Jan 30, 2008 4:20 pm
by macfreq
John,

So after looking at the Send Mail script step that can send multiple emails, is it possible to have this script step send a different attachment with each email?
Can the $path variable change during the Send Mail step?

I could make the PDF's in the temp directory and name them based on the Invoice number so they would be unique, but can the attachment path change during this step, or do I have to create a Loop?

Thanks.

PostPosted: Wed Jan 30, 2008 6:23 pm
by John Sindelar
You'd need to create a loop. =(