Download Mail - convert _incoming_mailRecords fields within php header

5 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 12, 2011   (RSS)

Re: [zick] Download Mail - convert _incoming_mailRecords fields within php header

By robin - July 11, 2011

Hey zick,

So you just need the variable names changed? Something like this might be helpful:

// load records
list($_incoming_mailRecords, $_incoming_mailMetaData) = getRecords(array(
'tableName' => '_incoming_mail',
));

foreach($_incoming_mailRecords as &$record) {
$record['title'] = $record['subject'];
$record['summary'] = $record['text'];
$record['media'] = $record['attachments'];
}
unset($record);


Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Download Mail - convert _incoming_mailRecords fields within php header

By Mikey - July 11, 2011

Hey zick,

So you just need the variable names changed? Something like this might be helpful:

// load records
list($_incoming_mailRecords, $_incoming_mailMetaData) = getRecords(array(
'tableName' => '_incoming_mail',
));

foreach($_incoming_mailRecords as &$record) {
$record['title'] = $record['subject'];
$record['summary'] = $record['text'];
$record['media'] = $record['attachments'];
}
unset($record);


Hope that helps,
Robin



Thanks Robin, this almost has me there... can you tell me how to combine the 'text' and 'html' fields from _incoming_mail into one, so it doesn't matter if some sends text or html in the message... they both become 'summary'.
// load records
list($_incoming_mailRecords, $_incoming_mailMetaData) = getRecords(array(
'tableName' => '_incoming_mail',
'perPage' => '5',
//'orderBy' => 'createdDate DESC',
));

foreach($_incoming_mailRecords as &$record) {
$record['title'] = $record['subject'];
$record['summary'] = $record['text'];
$record['summary'] = $record['html'];
$record['media'] = $record['attachments'];
}
unset($record);

$mediaMerge = array();
$mediaMerge = array_merge($galleryRecords, $newsRecords, $_incoming_mailRecords);


What I'm doing is merging three records into a single page using an array $mediaMerge = array();

Thanks,
Zick

Re: [zick] Download Mail - convert _incoming_mailRecords fields within php header

By robin - July 12, 2011

Hey Zick,

To do a straight combine this will work:
$record['summary'] = $record['text'] . $record['html'];

If you just want one or the other depending on which one is filled, this will help out:
$record['summary'] = coalesce($record['text'], $record['html']);
That is giving text the priority if they are both filled, swap the variables if you want html to have priority.


Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Download Mail - convert _incoming_mailRecords fields within php header

By Mikey - July 12, 2011

Thanks for the two solutions Robin!!!!
I've got them plugged into my site.
I really appreciate the help.
Zick