Posts: 22
Threads: 9
Joined: Mar 2009
Reputation:
1
Aug 20th, 2009, 11:42 PM
(This post was last modified: Aug 24th, 2009, 1:09 AM by nomad.)
Does anybody sending attachments by e-mail?
There is example in documentation:
{$attachment file="/folder/myfile.txt"} which works.
But how to use placeholders to construct the path and name of the file?
I have a name of the file, which is saved as text string in database field "soubor" and I like to use somethink like this in the body of email:
{$attachment file="$ANSWER_soubor"}
{$attachment file=$ANSWER_soubor}
{$attachment file="{$ANSWER_soubor}"}
{$attachment file={$ANSWER_soubor}}
No variant works at all.
Have somebody some solution?
Posts: 4
Threads: 0
Joined: Aug 2011
Reputation:
0
I nomad,
I've also the same problem.
I generate a file based on form values during the submission and store the server side filename and path in a hidden field.
But no way of passing it to attachment using
{$attachment file="<my field value>"}
Did you find any solution ?
jpenon
(Aug 20th, 2009, 11:42 PM)nomad Wrote: Does anybody sending attachments by e-mail?
There is example in documentation:
{$attachment file="/folder/myfile.txt"} which works.
But how to use placeholders to construct the path and name of the file?
I have a name of the file, which is saved as text string in database field "soubor" and I like to use somethink like this in the body of email:
{$attachment file="$ANSWER_soubor"}
{$attachment file=$ANSWER_soubor}
{$attachment file="{$ANSWER_soubor}"}
{$attachment file={$ANSWER_soubor}}
No variant works at all.
Have somebody some solution?
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey guys,
I'll look at this today.
Just to check: you're both using the Swift Mailer module, correct? The file attachments will only work with that module enabled (had to ask!).
- Ben
Posts: 4
Threads: 0
Joined: Aug 2011
Reputation:
0
I Ben,
Great to have a so quick feedback !
Yes I'm using Swift mailer and FT 2.1.0
jpenon
(Aug 28th, 2011, 8:35 AM)Ben Wrote: Hey guys,
I'll look at this today.
Just to check: you're both using the Swift Mailer module, correct? The file attachments will only work with that module enabled (had to ask!).
- Ben
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey guys,
I just tried it and it seems to work okay for me, as per the instructions here:
http://modules.formtools.org/swift_maile...ttachments
From what was posted, I think the value you're entering in the placeholder may be a little off - try just entering the file's field name as the field attribute value. e.g. if your form field looks like this:
Code: <input type="file" name="file123" />
In your email template, enter:
Code: {$attachment field="file123"}
Also, maybe double check that the file type you're uploading is on the white list of acceptable formats (for that, go to Settings -> Files).
Let me know if you still have trouble!
- Ben
Posts: 4
Threads: 0
Joined: Aug 2011
Reputation:
0
Hi,
I didn't have any file input field, because I didn't need to make end users upload files.
I generate a pdf report server side at end of submission (print out of submission including submission id in filename) and I want to send it per mail in attachement.
I store the file path of generated pdf in a field (different for each submission) and I need to have something working using
{attachment file="{ANSWER_my_field_containing_file_path}"}
I've tried to use a hidden file input and set the value in the form, but the field is not updated at all, because it need a upload action.
Did you have already have such requirement ! (no file upload from users, attaching a file with filname changing between submission) ?
Thanks a lot for the support !
jpenon
(Aug 28th, 2011, 11:03 AM)Ben Wrote: Hey guys,
I just tried it and it seems to work okay for me, as per the instructions here:
http://modules.formtools.org/swift_maile...ttachments
From what was posted, I think the value you're entering in the placeholder may be a little off - try just entering the file's field name as the field attribute value. e.g. if your form field looks like this:
Code: <input type="file" name="file123" />
In your email template, enter:
Code: {$attachment field="file123"}
Also, maybe double check that the file type you're uploading is on the white list of acceptable formats (for that, go to Settings -> Files).
Let me know if you still have trouble!
- Ben
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hi jpnenon,
Sorry for the long response time.
I'm afraid that this isn't possible with the existing code. The email file attachment functionality only has those two ways to upload the file mentioned above. But I can certainly see how the ability for it to load a filename from the value in the form submission would be very useful.
If you like, I could investigate updating the Core code to allow for this. I just glanced over the code and it shouldn't be too hard. Assuming it's relatively simple to accomplish, I won't make a separate release for it - but I'll include it in the next build and post the code to change here.
All the best -
Ben
Posts: 4
Threads: 0
Joined: Aug 2011
Reputation:
0
I Ben,
Thanks for the answer ! it will be great.
Excellent Job, congratulation !
jpenon
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hi jpnenon,
No problem! I'll look at it today.
- Ben
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Sep 4th, 2011, 2:58 PM
(This post was last modified: Sep 6th, 2011, 3:50 PM by Ben.)
Hi guys,
Okay, here's the new code. I'll include this in the next release, but for now you'll need to manually edit the /global/code/emails.php file. There, replace the _ft_extract_email_attachment_info function (starting at line 1392) with the following:
[EDIT - code removed. See next post for explanation]
Once that's done, in your email template, use this syntax:
Code: {$attachment fieldvalue="ANSWER_field1"}
The "fieldvalue" attribute is new. It does what you want: looks at the value stored in the field, then uses THAT as the file attachment location. In other words, in this example the field with the field name "field1" must contain the relative path of the file to attach.
Let me know if you have any trouble!
- Ben
|