Forums

Sending email using custom code

elvinjoe 23 Feb, 2012
Hello,

I want to send the email using form values,Can you please give me some sample code to send email using controller in custom code after email action.

Thanks for your help.
GreyHead 23 Feb, 2012
Hi elvinjoe ,

Why not just add a second Email action? Is there something you need to do that the action doesn't support?

Bob
elvinjoe 23 Feb, 2012
Hi GreyHead,

In my form I have hide/show values thats why I want to send email if it is loan category the email should have the loan category.
let's suppose I have dropdown
Category : "Loans","Deposit" having loans and deposits values if I select "Loans",I want to show subcategory : "personal loan","auto loan" dropdown box,if I click on Deposit I want to show
subcategory dropdown having "deposit cat1","deposit cat2".

category : <select name="category"><option value="1">Loans</option><option value="2">deposit</option></select>
if i use email action it is showing the option values 1 instead of that i want to show loan category if it is loan category.

so i would like to write the controller in custom code.

Please help me on this.
GreyHead 23 Feb, 2012
Hi elvinjoe ,

In a Custom Code action before the Email action (and before any Handle Arrays action) you need something like this:
<?php
$loans_array = array (
  1 => 'personal loan',
  2 => 'car loan',
  3 => 'mortgage'
;
$form->data['loan_type'] = $loans[$form->data['loan']]; 
?>

Then you can put {loan_type} in the Email template.

Bob
elvinjoe 23 Feb, 2012
Thanks for your reply,I will try that.

Can you please tell me how to get the dynamic data from tables,lets suppose loan is table in my db i want to list the values from loans in dropdown in my form
elvinjoe 23 Feb, 2012
How to check conditions in template email,let's suppose
in below template i want to show loan product in email if the product_interest is "loan".Please help me on this.

<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td>
			Product you are interested in
		</td>
		<td>
			{product_interest}
		</td>
	</tr>
        <tr>
		<td>
			Loan Product
		</td>
		<td>
			{loan_product}
		</td>
	</tr>
	<tr>
		<td>
			Loan Amount (VND)
		</td>
		<td>
			{loan_amount}
		</td>
	</tr>
	<tr>
		<td>
			Loan Tenor
		</td>
		<td>
			{loan_tenor}
		</td>
	</tr>
	<tr>
		<td>
			Your Comments
		</td>
		<td>
			{comments}
		</td>
	</tr>
	<tr>
		<td colspan='2'>
			Your Personal Information
		</td>
	</tr>
	<tr>
		<td>
			Title
		</td>
		<td>
			{salutation}
		</td>
	</tr>
	<tr>
		<td>
			First Name
		</td>
		<td>
			{first_name}
		</td>
	</tr>
	<tr>
		<td>
			Middle Name
		</td>
		<td>
			{middle_name}
		</td>
	</tr>
	<tr>
		<td>
			Last Name
		</td>
		<td>
			{last_name}
		</td>
	</tr>
	<tr>
		<td>
			Date of Birth
		</td>
		<td>
			{dob}
		</td>
	</tr>
	<tr>
		<td>
			ID/Passport Number
		</td>
		<td>
			{id_passport_num}
		</td>
	</tr>
	<tr>
		<td>
			Mobile Number Country
		</td>
		<td>
			{mobile_phone_country}
		</td>
	</tr>
	<tr>
		<td>
			Mobile Number Network
		</td>
		<td>
			{mobile_phone_network}
		</td>
	</tr>
	<tr>
		<td>
			Mobile Number
		</td>
		<td>
			{mobile_phone}
		</td>
	</tr>
	<tr>
		<td>
			Home/Office Phone Country
		</td>
		<td>
			{home_office_phone_country}
		</td>
	</tr>
	<tr>
		<td>
			Home/Office Network
		</td>
		<td>
			{home_office_phone_network}
		</td>
	</tr>
	<tr>
		<td>
			Home/Office Number
		</td>
		<td>
			{home_office_phone}
		</td>
	</tr>
	<tr>
		<td>
			Email
		</td>
		<td>
			{email}
		</td>
	</tr>
	<tr>
		<td>
			Are you salaried or self-employed?
		</td>
		<td>
			{occupation}
		</td>
	</tr>
	<tr>
		<td>
			Average Monthly Income
		</td>
		<td>
			{income}
		</td>
	</tr>
	<tr>
		<td>
			How did you hear about us?
		</td>
		<td>
			{media_source}
		</td>
	</tr>
	<tr>
		<td>
			Please keep me informed of promotional information about
		</td>
		<td>
			{keep_informed}
		</td>
	</tr>
	
</table>
GreyHead 23 Feb, 2012
Hi elvinjoe,

<table cellpadding="0" cellspacing="0" border="0">
   <tr>
      <td>
         Product you are interested in
      </td>
<?php 
if ( $form->data['product_interest'] == 'loan' ) {
?>
      <td>
         {product_interest}
      </td>
   </tr>
        <tr>
      <td>
         Loan Product
      </td>
      <td>
         {loan_product}
      </td>
   </tr>
   <tr>
      <td>
         Loan Amount (VND)
      </td>
      <td>
         {loan_amount}
      </td>
   </tr>
   <tr>
      <td>
         Loan Tenor
      </td>
      <td>
         {loan_tenor}
      </td>
   </tr>
<?php
}
?>
GreyHead 23 Feb, 2012
Hi elvinjoe,

To get data from tables you probably need to use either the DB Record Loader action for a single record; or the DB Multi-record loader.

Bob
This topic is locked and no more replies can be posted.