Blogs
17
July
<?php
$template_name = 'Greetings from Urdhva-tech';
require_once('modules/EmailTemplates/EmailTemplate.php');
$template = new EmailTemplate();
$template->retrieve_by_string_fields(array('name' => $template_name,'type'=>'email'));
$oContact = new Contact();
$oContact->retrieve("36CharacterContactID"); //Contact ID
//Parse Subject If we used variable in subject
$template->subject = $template->parse_template_bean($template->subject,$oContact->module_dir, $oContact);
//Parse Body HTML
$template->body_html = $template->parse_template_bean($template->body_html,$oContact->module_dir, $oContact);
//Here you will have a result
print "<pre>";
print_r(from_html($template->body_html));
Hello Sallie Elzey,
Greetings from Urdhva-tech.
Here we have example of some variable.
Thanks
Chris Olliver
July
Greetings from Urdhva tech!
Here is an code snippet how SugarCRM parse an Email Template.
Let's have an example
Here I have created email template from Emails->Create Email Template
Template body :
Hello $contact_name,
Greetings from Urdhva-tech.
Here we have example of some variable.
Thanks
$contact_user_full_name
$contact_user_phone_mobile
Greetings from Urdhva-tech.
Here we have example of some variable.
First Name : | $contact_first_name |
Last Name : | $contact_last_name |
Email : | $contact_email1 |
Thanks
$contact_user_full_name
$contact_user_phone_mobile
any custom script.php
<?php
$template_name = 'Greetings from Urdhva-tech';
require_once('modules/EmailTemplates/EmailTemplate.php');
$template = new EmailTemplate();
$template->retrieve_by_string_fields(array('name' => $template_name,'type'=>'email'));
$oContact = new Contact();
$oContact->retrieve("36CharacterContactID"); //Contact ID
//Parse Subject If we used variable in subject
$template->subject = $template->parse_template_bean($template->subject,$oContact->module_dir, $oContact);
//Parse Body HTML
$template->body_html = $template->parse_template_bean($template->body_html,$oContact->module_dir, $oContact);
//Here you will have a result
print "<pre>";
print_r(from_html($template->body_html));
Output of script will be this.
Sallie Elzey is the name of contact which i used at time of contact retrieve.
Hello Sallie Elzey,
Greetings from Urdhva-tech.
Here we have example of some variable.
First Name : | Sallie |
Last Name : | Elzey |
Email : | This email address is being protected from spambots. You need JavaScript enabled to view it. |
Thanks
Chris Olliver
Download attachments:
Comments
- No Comments Found.