function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
atulit27atulit27 

How to send content of textarea in an email template?

when I am using the textarea tag its showing the textarea and we can enterthe text too, but when we send that template the text in that textarea is not being sent.

ministe2003ministe2003

So you have an email template which contains a reference to that field?  Sounds like you're not saving the record before you send the email.  If you fill out the field then save the email, if you havent saved it to the database then that text you've written is not accessible by the email template and it will render whatever the field within the database contains, which in this case, is blank.

 

Save the record before you send the email and you should be fine.

atulit27atulit27

but in template how can we save the record in database before sending.....

ministe2003ministe2003

You dont do it in the template, you do it before you call the template.

I'm assuming since you've posted this in the Visualforce forum that you're sending it on a button press on a VF page?

You have a few options, I'll list 3 that I'd choose from:

1) if you're not using apex, have a button called Save where action="{!save}".  This saves the record to the database.  Then have another button which sends the email.

2) you'll still need the save button, but instead of a 2nd button click to send the email, use a workflow that runs on insert (or insert and update, depeding how you want it to work)

3) use apex.  Have a button which calls a custom method, lets call it SaveAndSend().  In that method save the record then create the Mail call to send your email template.  The documentation will show you how to do that.

atulit27atulit27

I am using an email template with visualforce and we can't have button on the tempelate to save content may be we can use some variable to store and then access data from that variable while we send the email but it should happen dynamically.that data gets stored in variable and sent with the email.

ministe2003ministe2003

I think we're talking cross purposes.  How are you sending the email?  Is it a workflow action?  Is it a user button press?  Is it fired by a trigger?

atulit27atulit27

it is a user button press using the opportunity object. Where user selects the tempelate before sending the mail.

But in template there should be a space where we can type and include our notes or comments and send with the mail.

ministe2003ministe2003

You cant dynamically add data to the template, you need to store the data in a field and reference that field.  Are you using a custom button on the standard opportunity page or is your opportunity page a custom visalforce page?  I'm assuming that the button you mentioned opens up a custom visualforce page where the user selects the template?  If so is there an apex controller/extension involved?

atulit27atulit27

I am creating an email template under the communication templates using visualforce and this template is used by the opportunity object where it selects the different templates but i want to add some text in the template before sending that email would it be possible?

ministe2003ministe2003

You are misunderstanding.  I'm not asking how you've made the email template.  I know you have created a visualforce template and saved it.  What I am asking is how you are firing that template.

Yes it is possible to add the text to the template, but only by saving that text to a field on the opportunity first and then referencing that field in your template.  You have to populate the text field with data, SAVE IT and only then send the email.

atulit27atulit27

Okkk I understand that we have to save the text before sending the email. But how do we create a save button over the email layout in opportunitiy object.

In activity history there is a send an email button it redirects us to page where we select our email template but i didnt know how to add a save button over there where we select a template so that we can save our text before sending our email?

ministe2003ministe2003

OK I see, you're using the Activity History button.  I assumed you were using a custom button.  Well the easiest way around this is just to put a field on your opportunity page layout, perhaps called Email Comments or something and then before you send your email, write the comments in there and save.  Reference that field in your email template to get the text