# Send email to specific workgroup

**URL:** <https://developer.sailpoint.com/discuss/t/send-email-to-specific-workgroup/3087>\
**Category:** IIQ Discussion and Questions\
**Created:** [February 18, 2022, 2:05pm UTC](https://developer.sailpoint.com/discuss/t/send-email-to-specific-workgroup/3087 "2022-02-18T14:05:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharshini](https://avatars.discourse-cdn.com/v4/letter/t/ecc23a/32.png) [@tharshini](https://developer.sailpoint.com/discuss/u/tharshini)\
**Post date:** [February 18, 2022, 2:05pm UTC](https://developer.sailpoint.com/discuss/t/send-email-to-specific-workgroup/3087/1 "2022-02-18T14:05:46Z")

</div>

Hi All,

I want to send the new joiner notification to users in specific workgroup (depending on their department). For example, if they are IT Security, a new email will be send to the admins of IT Security Workgroup (there are multiple admin in the workgroup). How can I achieve that in a rule under _to_ argument in the default notify workflow?

Below is snapshot of my logic:

```auto

Identity employee = context.getObjectByName(Identity.Class, identityName);
String employeeJobTitle = identity.getAttribute("title")

//Send email based on Job Title
if (employeeJobTitle.equalsIgnoreCase("Database")){

	emailDest = //send email to Database Admin workgroup

}else if(employeeJobTitle.equalsIgnoreCase("IT Security")){

	emailDest = //send email to IT Security Admin workgroup
}else{//All other users

	emailDest = //Send email to their managers

}

```

What classes would return the manager email and also return the emails of users in the specific workgroup?

---

<div class="post-metadata">

**Author:** ![paul\_wheeler](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@paul\_wheeler](https://developer.sailpoint.com/discuss/u/paul_wheeler)\
**Post date:** [February 18, 2022, 2:25pm UTC](https://developer.sailpoint.com/discuss/t/send-email-to-specific-workgroup/3087/2 "2022-02-18T14:25:56Z")

</div>

To get the email addresses of everyone in a workgroup, use:

```auto
Identity workgroup = context.getObjectByName(context, workgroupName);
List emails = sailpoint.api.ObjectUtil.getEffectiveEmails(context, workgroup);

```

To get the manager email:

```auto
String email;
Identity manager = identity.getManager();
if (manager != null) {
   email = manager.getEmail();
}

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [July 19, 2023, 2:25pm UTC](https://developer.sailpoint.com/discuss/t/send-email-to-specific-workgroup/3087/3 "2023-07-19T14:25:30Z")

</div>

Closed on July 19, 2023, 2:25pm UTC


