Generating HTML-Email by script

  • Posts: 2726
  • Karma: 93
  • Thank you received: 369

mihaela replied the topic: Generating HTML-Email by script

Hello,

Here is the new code that answers your questions:
$this->execPieceByName('ff_InitLib');
$from = 'test@test.com';
$fromname =  'yourname';
$subject = 'mysubject';

$recipient = 'youremail@gmail.com'; 


$attachment=null;
$isHtml = true;

$body =  "
<html><body><table style='color:blue;' border='1' >";

if(ff_getSubmit('name') < ff_getSubmit('name_max') ) {
   $diff = ff_getSubmit('name_max') - ff_getSubmit('name');
   $body .= "<tr>
<td>
   <strong>". $name= ff_getSubmit('name') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('name_min') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('name_max') . "</strong>
</td>
<td>
   <strong>". $diff . "</strong>
</td>
</tr>";
}

if(ff_getSubmit('example') < ff_getSubmit('example_max') ) {
  $diff = ff_getSubmit('example_max') - ff_getSubmit('example');
	$body .= "<tr>
<td>
   <strong>". $name= ff_getSubmit('example') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('example_min') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('example_max') . "</strong>
</td>
<td>
   <strong>". $diff . "</strong>
</td>
</tr>";
}

if(if(ff_getSubmit('another') < ff_getSubmit('another_max') )) {
  $diff = ff_getSubmit('another_max') - ff_getSubmit('another');
	$body .= "<tr>
<td>
   <strong>". $name= ff_getSubmit('another') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('another_min') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('another_max') . "</strong>
</td>
<td>
   <strong>". $diff . "</strong>
</td>
</tr>";
}

$body .= </table>
</body></html>";

$this->sendMail($from, $fromname, $recipient, $subject, $body, $attachment, $isHtml); 
NOTE: I am not sure which field you want to subtract, so adjust this if necessary.

Let me know whether this works as you want.

Regards,

Mihaela
#238358
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

Mister.Miracle replied the topic: Generating HTML-Email by script

Hi thank you for your helping - again and again :-)

i think i can trans-code it also to the for-($i;$i<3;$i+1)-code before!

i have a lot of elements (maybe 60-90 elements) i have to rename by element1, element2, element3 and also element1_min, element1_max, ... and so on

so i can use your coding with the recursion.

now i think about an possible error:
1.) what if element10 was deleted, because of changing something. Does the for($i...)-code works also?
2.) how can i calculate the last element of for-loop?
3.) while programming javascript... is it possible something like this.
everythin is write in a array? array[$i], array[$i][Min] and array[$i][Max]
so i could calculate length of array to use in for-loop?

it was only thinking about it... but i dont know a lot about javascript :-( Because of this i asked...

thank you a lot
#238377
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

Mister.Miracle replied the topic: Generating HTML-Email by script

ah... i see one problem:

ff_getSubmit('example') will give me the value, the user entered into field example. is it right?

i need also the title of field example, i give to the field in the form configuration.
#238378
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

Mister.Miracle replied the topic: Generating HTML-Email by script

hi,
how i can use the ff_get-function to get the title of the field and not the submitted value?
#238471
  • Posts: 2726
  • Karma: 93
  • Thank you received: 369

mihaela replied the topic: Generating HTML-Email by script

Hello,

I will try to give answers to your questions briefly.

Firstly, there is no such function that would allow you to get the field's name as it is ff_getSubmit('FIELDNAME') to fetch the value.

You could get the field's titles and values in a loop, but that would require a bit different approach.

Here is the code to fetch the values:
foreach ($this->maildata as $data) {
   $body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
 
}
You would have to adjust the code quite a lot to get the looks that you want.

I will give you more instructions when you decide which approach you will use to create an email.

Regards,

Mihaela
#238478
Moderators: ForumSupporttomeperica
Time to create page: 0.066 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here