This question about Using an extension: Answered

Is it possible to add more form fields as just typical email fields?

Dear all,

I'd like to enter a form in foswiki with sendemail-plugin.
No problem when using it, just to send normal emails.

But is it possible to enter more form fields just as in a
simple html-form? If yes, how do I send it out?

Best regards
Patrick

I don't want to send emails in html-format, but I'd like to send more fields
as only "from, to, subject, body". Is it possible to send fields declared by myself
getting a comfortable form from foswiki?
I may enter a normal html-form in foswiki, but there's a security-alert before
sending email....
Best regards
Patrick


You can only use fields that are known by email clients, such as subject, cc, bcc, and so on. See http://en.wikipedia.org/wiki/Email

You can compose the email from Foswiki data form field values though, for instance by passing in the body field: %FORMFIELD{"Category"}% %FORMFIELD{"Summary"}%

-- ArthurClemens - 17 Nov 2010


But how do I have to use it?
I tried it that way:

<textarea name="body" cols="80" rows="6">
Title: %FORMFIELD{"Title"}%
Summary: %FORMFIELD{"Summary"}%
</textarea>

But it's a textarea. I'd like to have some input fields as and tried it
that way:

<input type="hidden" name="body" value=", " />
<input type="text" name="%FORMFIELD{"Title"}%" size="30" />
<input type="text" name="%FORMFIELD{"Summary"}%" size="30" />
...

But it doesn't work.
Do you have a solution for me?

Best regards
Patrick

The name attribute should not be changed. These are to, subject, body, etcetera. If you want to pass form field values, pass then in the value attribute like <input type="text" name="body" value="%FORMFIELD{"Summary"}%" size="30" />.

If that does not work, start from the basic example http://foswiki.org/Extensions/SendEmailPlugin#Example_with_a_handcrafted_HTML and see if you can send emails using this (on your own site, because here the plugin is not installed). Then adapt the code to let the body field have different values.

-- ArthurClemens - 17 Nov 2010


I think I'm getting nuts
Just tried this one, but it still doesn't work....seems I'm a noob frown, sad smile

Maybe you've got a hint for me?

PatrickOschwald

You will have to get more specific in what does not work.

-- ArthurClemens - 17 Nov 2010


I tried lots...that was my last example, but I don't get along, that field "additional" will be sent by eMail in any way. I've tested it by hiding field "body" and tried to fill in field "additional" and lots of other ways. But I don't get it working.
At least I should add about 20 fields....

<div class="foswikiFormStep"><input class="foswikiInputField" id="to" name="to" size="30" type="text" value="%URLPARAM{"to"}%" /></div>
<div class="foswikiFormStep"><input type="text" class="foswikiInputField" id="subject" name="subject" size="70" value="%URLPARAM{"subject"}%" /></div>
<div class="foswikiFormStep"><textarea class="foswikiInputField" cols="70" name="body" rows="6" style="width:100%">%URLPARAM{"body"}%</textarea></div>
<div class="foswikiFormStep"><input type="text" class="foswikiInputField" id="additional" name="additional" size="70" value="%URLPARAM{"additional"}%" /></div>


additional will not be recognized by email programs. You need to put all that stuff in body.

If you don't need or want user interaction with the contents of the fields, you better not put the text in a textarea but in a hidden field instead. So:

<input name="body" type="hidden" value="%URLPARAM{"body"}%%URLPARAM{"additional"}%" />

-- ArthurClemens - 18 Nov 2010


okay, I tried that before.... but what do I have to do, to fill field additional? I'd like to have it as a normal form field, where you can enter some text. In fact I'd like to fill the body-field with about 20 input fields?! And in each one it should be possible to enter some kind of free text.

PatrickOschwald


This is only possible with javascript (that you need to write) to set the contents of the body field with the contents of other fields, or by using FormPlugin, see FormPlugin: Substitution of field references.

-- ArthurClemens - 18 Nov 2010

The only way to transport net data over email is by putting it into the body. The other input fields of the HTML form are used by the email transport mechanisms. So if you want to send an email containing any data, then they ultimately have to be put into the body element of the HTML form from which the email is created.

You already outlined that above using a textarea with multiple lines of the format Title: %FORMFIELD{"Title"}% .

Or use any other format suitable to be parsed by the receiving side (xml, json, whatever). But key:value lines is fine as well, as long as your values don't contain newlines, these will have to be encoded in that case using %ENCODE.

The FindingANewNameSurvey has been done that way. Here are two other examples of a more complex setup where data is gathered using a wizard which finally sends out the results.

-- MichaelDaum - 16 Dec 2010

QuestionForm edit

Subject Using an extension
Extension SendEmailPlugin
Version Foswiki 1.0.7
Status Answered
Topic revision: r14 - 16 Dec 2010, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy