Tuesday 05 July 2005 6:03:37 am
ok, today my workflow is able to send a mail to all the newsletter receivers (class ID=36) $listeAbonnes = eZContentObject::fetchList( true,
array( 'contentclass_id' => 36,
'status' => EZ_CONTENT_OBJECT_STATUS_PUBLISHED)
);
foreach($listeAbonnes as $Abonnes){
$data_map=& $Abonnes->attribute( 'data_map' );
$email = $data_map['email']->content();
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'lib/ezutils/classes/ezmail.php' );
$mail = new eZMail();
include_once( "kernel/common/template.php" );
include_once( 'lib/ezutils/classes/ezmail.php' );
include_once( 'lib/ezutils/classes/ezmailtransport.php' );
include_once( "kernel/classes/ezcontentclass.php" );
$nodeID=& eZContentObjectTreeNode::fetch( $nodeID );
$mail_tpl =& templateInit();
$mail_tpl->setVariable( 'node_id', $nodeID );
$mailTemplateResult =& $mail_tpl->fetch( 'design:newsletter/newsletter.tpl' );
$mailTemplateResult =$mailTemplateResult .'zut';
$emailSender ='info@bazaravenue.com';
$receiver = $email;
$mail->setBody( $mailTemplateResult );
$mail->setSender( $emailSender );
$mail->setReceiver( $receiver );
$subject = 'Nouvelle Newsletter';
$mail->setSubject( $subject );
//$mail->setBody( $body );
$mailResult = eZMailTransport::send( $mail );}
//return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
but the call of the template (for sending the content of newsletter doesnt work...) more explanations here:http://ez.no/community/forum/developer/how_to_send_an_object_into_email
|