sugarcrmsugarbean

Retrieve SugarCRM employee emails


I'm writing some code for sugarCRM, and I'd like to notify employees via email. I'm using the active record model to get employees, but their emails are nowhere to be found.

$employees = BeanFactory::getBean('Employees')->get_full_list();

How do I get the active employee emails via this interface? I need to pluck them out of the records and add them to the email I'm sending out.


Solution

  • To save user's email address use this:

    $sea = new SugarEmailAddress;
    $sea->addAddress($bean->email1, true);
    $sea->save($newUser->id, "Users");
    

    To retrieve primary email address use this:

    $primary_email=$user->emailAddress->getPrimaryAddress($user);
    

    Hope this will help you... :)

    Checkout this for more: SugarCRM Developer