PHP Code:
// find an existing email with the same name and status is Sent
$emailId = record\findOne('Email', 'createdAt', 'desc', 'name=', name, 'status=', 'Sent');
// Get the body field
$body = record\attribute('Email', $emailId, 'body');
// compare the length of the two bodies using string\replace and string\match to remove the img tag
ifThen(string\length(string\replace($body, string\match($body, '/<img[^>]+>/'), '')) == string\length(string\replace(body, string\match(body, '/<img[^>]+>/'), '')),
record\update('Email', id, 'deleted', true)
);
Leave a comment: