Hello, I’m very new to xwiki, ready and dedicated to learn.
I’m running into an issue where I don’t know how to mail a form with multiple input types. A simple single textfield is no problem. But I’m looking for examples where dropdowns, radio’s etc. are used and shaped in de sent email.
Anyone have proven examples?
Thanks in advance!!
Hi Richard. Not sure I understand the question. If you’re looking to send a mail containing HTML then it’s quite simple. See https://extensions.xwiki.org/xwiki/bin/view/Extension/Mail%20Sender%20API
Ha Vincent,
Thank you for the reply! I’ve read that page but it leads to no aswer for me. But as I said, I’m new to xwiki and its programming languages…
What I’m trying to accomplish is that I want to make a HTML form with different input types like textfield, radio’s, dropdowns etc. in xWiki and send it to an e-mailadres. So far I’m only capable of sending 1 textfield… Below is a simple example which works. But I want to use more input types, AND I want to make them up in the “to be send” e-mail…
I hope this is somewhat clearer…
{{velocity}}
#if("$!{request.action}" == 'send_mail' && "$!{request.lastname}" == '')
#if("$!request.subject" != '')
#set ($message = $services.mailsender.createMessage("no-reply@xwiki.domain.nl", "r.mulder@domain.nl", $request.subject))
#set ($discard = $message.addPart("text/plain", "$!request.message"))
#set ($result = $services.mailsender.send([$message], 'database'))
#else
{{error}}Onderwerp is verplicht!{{/error}}
#end
#end
#if ($services.mailsender.lastError)
{{error}}$exceptiontool.getStackTrace($services.mailsender.lastError){{/error}}
#end
#set ($statuses = $result.statusResult.getByState('FAILED'))
#if ($statuses.hasNext())
{{error}}Error: $statuses.next().error{{/error}}
#end
{{html wiki=true}}
<form action="" method="post">
<input name="action" value="send_mail" type="hidden" />
## Botvangertje
<div class="hidden">
<input name="lastname" type="text" />
</div>
<fieldset>
<input type="hidden" name="recipient" value="r.mulder@domain.nl"/><br />
**Onderwerp:**<br />
<input type="text" name="subject" /><br />
**Bericht:**<br />
<textarea name="message" style="width:99%;" rows=10>Bericht opties.</textarea>
</fieldset>
<div>
<span class="buttonwrapper"><input type="submit" class="button" value="Verzenden" /></span>
<span class="buttonwrapper"><input type="reset" class="button" value="Wissen" /></span>
</div>
</form>
{{/html}}
{{/velocity}}
I’ve checked your code and it seems you don’t want to send the HTML FORM by email as you said but the values entered in the FORM by users… Right?
I don’t see the problem with your code. You’re sending some text email with a content of "$!request.message"
. If you want to send more you need to build the string that you want to send.
For example "Message: $!request.message\nSubject: $request.subject"
.
If you want to send HTML then you need to build the HTML you want to send. See examples on the link I gave you in my first reply.
I’ve checked your code and it seems you don’t want to send the HTML FORM by email as you said but the values entered in the FORM by users… Right? <= Right!
I don’t see the problem with your code. You’re sending some text email with a content of "$!request.message"
. *If you want to send more you need to build the string that you want to send.
For example "Message: $!request.message\nSubject: $request.subject"
.
If you want to send HTML then you need to build the HTML you want to send. See examples on the link I gave you in my first reply.
That clears things up! Thank you!!