Notes Report logic hook

My goal is to send every day at 6 pm a report of all the notes made every day by an specific person, So they way this can be done is by going through the targets and getting the notes of each target by loading right relationship .

function sendSuiteMail($from,$fromName,$body,$subject){
		global $current_user;
		console.log($current_user->name);
		require_once $_SERVER[DOCUMENT_ROOT].'/include/SugarPHPMailer.php';
		$mailer=new SugarPHPMailer();
		$mailer->prepForOutbound();
		$mailer->setMailerForSystem();
		$message = "<html>$current_user->name<br>You logged into ECS CRM today</html>";
		$mailer->From = "$from";
		$mailer->FromName = "$fromName";
		$mailer->IsHTML(true);
		$mailer->Subject = $subject;
		$mailer->Body = "$body";
		//$mailer->AddAddress("$current_user->email1");
		$mailer->AddAddress("dsanchez@ecs-support.com");
		$mailer->Send();
	}
	class reportSend{
		function after_login_methodReport($bean ,$event, $arguments){
			$fromName = "ECS CRM";
			$from= "crm@ecs-support.com";
			$subject = "New Alert for $bean->name";
			$accBean = BeanFactory::getBean('Prospects'); 
			$accBeans = $accBean->get_full_list('name');
			$body = "<html>";
			foreach($accBeans as $curBean){
				$body.=$curBean->name." <br>";
			}
			$body.=count($accBeans);
			$body.="</html>";
			sendSuiteMail($from,$fromName,$body,$subject);
		}
	}

I tried to load a relationship ($accBean->load_relationship(‘prospect_notes’) but its not working , any ideas?

Unfortunately you hit the peculiar scenario where the names of relationships don’t always adhere to the framework they claim to be.

    $curBean->load_relationship('notes');
        $relate = $curBean->notes->get();
        foreach($relate as $notebean_id){
                $noteBean = BeanFactory::getBean('Notes', $notebean_id); 
                $body .= "\n\n $noteBean->name \n\n";
        }

The correct relationship is actually the name from the vardefs, not the relationship link that we refer to.
Hope that helps.

A code-less way to achieve that - would be to try using the builtin modules Reports (to filter down the notes you want) and Scheduled Report sub-panel to decide when to email it and to whom.
You probably knew that -apologies if so.