CodeIgniter Forums
Email Class - View as Message? [SOLVED] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Email Class - View as Message? [SOLVED] (/showthread.php?tid=12515)



Email Class - View as Message? [SOLVED] - El Forum - 10-22-2008

[eluser]Joakim_[/eluser]
Hi. Is it possible to use a view (with html) as the message for the Email Class?

I tried with no luck. This is how the code looks:

Code:
...

$config['mailtype'] = 'html';
$this->email->initialize($config);

$message = $this->load->view('summary');

$this->email->subject('Summary');
$this->email->message($message);

$this->email->send();

...

Thank you very much!


Email Class - View as Message? [SOLVED] - El Forum - 10-22-2008

[eluser]GSV Sleeper Service[/eluser]
have you tried this?
Code:
$message = $this->load->view('summary','',true);
adding 'true' as the third parameter to load->view will return the view as a string.


Email Class - View as Message? [SOLVED] - El Forum - 10-22-2008

[eluser]sharpe[/eluser]
You can pass also variables
Code:
$data['username'] = 'Joe';
$message = $this->load->view('summary',$data,TRUE);



Email Class - View as Message? [SOLVED] - El Forum - 10-22-2008

[eluser]Joakim_[/eluser]
Awesome, it works! Thank you very much! Smile