Developer forum

Forum » Development » Send a email with template

Send a email with template

Ricardo Pereira
Reply

Hi guys,

How can I send an email with a custom template that allow translate tags?
Before I could use the FormMailer but this will be discontinued.

Any ideas or suggestions?

 

Thank you,

Ricardo


Replies

 
Nicolai Høeg Pedersen
Reply

You could use forms for editors...?

 
Ricardo Pereira
Reply

In that case I think not, because the user can choose one of multiple email templates in the front-end.

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Yes, you can do that with Forms for editors as well.

You can create a field with the system name "ReceiptTemplate" and if you let it have a value of "MyCustomMailTemplate.html" and place it in the folder "/Templates/Forms/Mail", that template will be used when the receipt mail is sent. If you make it a select box you can have the user choose whatever he wants.

You can also override any other paragraph setting, i.e. these related to the mail being send:

ReceiptSubject (String, mail subject)
ReceiptSender (String, valid email address)
ReceiptCC (String, valid email addresses seperated by ",")
ReceiptBCC (String, valid email addresses seperated by ",")
ReceiptText_DataXML (String, the mail text - can be HTML)

That would give you something like this:

<input type="text" name="ReceiptTemplate" value="MyCustomMailTemplate.html">
<input type="text" name="ReceiptSubject" value="This is you receipt mail">
<input type="text" name="ReceiptSender" value="noreply@domain.com">
<input type="text" name="ReceiptCC" value="signup@domain.com">
<input type="text" name="ReceiptBCC" value="sales@domain.com, leads@domain.com">
<input type="text" name="ReceiptText_DataXML" value="<h1>Thank you!</h1>See you soon.">

BR Nicolai

Votes for this answer: 1
 
Ricardo Pereira
Reply

Thank you, Nicolai!

 
Lars Larsen
Lars Larsen
Reply

Hi

I have tried overwriting the receipt template. But this doesn't work if the receipt template is set to "Automatic". It only works when I choose a receipt template then the template in the field (ReceiptTemplate) in the form is used! This must be a bug, right?

Running DW v.9.3.5

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Lars

No, that is specifically coded to use automatic templates when specified.

But luckily for you that setting can also be overriden. So set a hidden field with name "UseReceiptTemplate" to the value "1" and your custom template will be used.

BR Nicolai

Votes for this answer: 1

 

You must be logged in to post in the forum