I want to send the list of some of the node information in email to users.
I have created table of information using theme('table') function. Now I want to send this table to email to user.
Is it possible to send theme('table') using Email ?
Will it work when user will see the information in Email ?
I am sending table structure in Email, is this possible to achieve it?
I have attached the relevant code to generate table and send mail.
$header = array(
array('data' => t('Title'), 'field' => 'n.title'),
array('data' => t('Author'), 'field' => 'u.name'),
);
$query = db_select('node', 'n');
$query->leftjoin('users', 'u', 'u.uid = n.uid');
$query->fields('n',array('title', 'created', 'nid', 'type'))
->fields('u',array('name', 'uid'))
->fields('b',array('body_value'))
->fields('c',array('subject'));
$query->condition(db_or()->condition('n.type', 'post', '=')->condition('n.type', 'forum', '='));
$query->condition('n.uid', $user->uid, '=');
$result = $query->execute();
$rows = array();
foreach ($result as $row) {
if($row->subject) {
$titlerow = l($row->subject, 'node/'. $row->nid).'</br>'. $row-
}
$rows[] = array( $titlerow,
t('Reply Posted by: ').l($row->name, 'user/'. $row->uid)
);
}
$params = theme('table', array('header' => $header, 'rows' => $rows, array('class' => array('ajax-sample-table'))));
$language = language_default();
$send = TRUE;
$result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
if ($result['result'] == TRUE) {
drupal_set_message(t('Your message has been sent.'));
}