Hi,
I am new to ACS. I'd like to send email with my custom email. so I created email template as follow:
Name Subject Body first judul isi nya {{isi}}the i use the js sdk as follow:
var data = { recipients: 'maul_firdaus@yahoo.com', template: 'first', dynamic_fields: {'isi':'asik'} }; sdk.sendRequest('custom_mailer/email_from_template.json', 'POST', data, callback);And the logs shows:
Request Time 2012-09-01 00:47:20 UTC Request Name POST /v1/custom_mailer/email_from_template.json Response Status 200 Parameters { "recipients" => "maul_firdaus@yahoo.com", "template" => "first", "dynamic_fields" => "{"isi"=>"asik"}", "suppress_response_codes" => "true", "key" => "mD3EaYzwvrw5fxitZDPqtil6zgF8lLpu", "_session_id" => "NyvTEU4yvsIqiOBUEUeDetAQa1A", "controller" => "custom_mailer", "action" => "email_from_template", "version" => "v1", "format" => "json" } User Agent Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3But I still failed to fill my dynamic_fields, which in my case called 'isi' with my desired value.
Could someone please show me what I did wrong?
Thank you, Fajar
4 Answers
have you tried
var data = { recipients: 'maul_firdaus@yahoo.com', template: 'first', dynamic_fields: JSON.stringify({'isi':'asik'}) };
goto acs webconsole, there is tab called email template, you can create a template in xml then save it. then in your email api, pass the email template name.
i tried this way and it works for me, the point is don't include them in dynamic_fields:
var data = { recipients: 'maul_firdaus@yahoo.com', template: 'first', isi:'asik' }; sdk.sendRequest('custom_mailer/email_from_template.json', 'POST', data, callback);
Fajar,
This code works fine for me. The log shows dinamic_fields populated:
Cloud.Emails.send({ template : 'your_template_name', recipients : 'email@mail.com', "dynamic fields" : "name=joe" }, function(e) { if (e.success) { alert('Cadastro efetuado com sucesso!'); } else { alert('Error:\\n' + ((e.error && e.message) || JSON.stringify(e))); } });
Your Answer
Think you can help? Login to answer this question!