# Email task recipient dynamically defined

**URL:** <https://forum.flowable.org/t/email-task-recipient-dynamically-defined/7682>\
**Category:** Flowable Engine\
**Created:** [March 31, 2021, 9:01am UTC](https://forum.flowable.org/t/email-task-recipient-dynamically-defined/7682 "2021-03-31T09:01:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flk2a](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@flk2a](https://forum.flowable.org/u/flk2a)\
**Post date:** [March 31, 2021, 9:01am UTC](https://forum.flowable.org/t/email-task-recipient-dynamically-defined/7682/1 "2021-03-31T09:01:45Z")

</div>

Dear all,

I am a beginner in flowable. I am trying to create an email task where the email address of the recipient “to” would be dynamically defined, selecting a “user name” within the IDM in a user task.

To be more clear:

-In my user task, I put in a variable “employee” a user name from the IDM  
-In my email task, in the “to” I put something like {$employee.email} to obtain the email related to the user name stored in “employee”.

Do you think it is possible to do something like that ?

Thank you in advance for you help.

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [March 31, 2021, 12:40pm UTC](https://forum.flowable.org/t/email-task-recipient-dynamically-defined/7682/2 "2021-03-31T12:40:04Z")

</div>

Hi,

the expression

```
${employee.email}

```

is evaluated to email (e.g. “[joe.doe@test.com](mailto:joe.doe@test.com)”) only when employee is a structure which contains `email` property. That’s why you have store a user into variable (I would not recommend it) or provide a service which will obtain email for given userId in the expression.

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![flk2a](https://avatars.discourse-cdn.com/v4/letter/f/67e7ee/32.png) [@flk2a](https://forum.flowable.org/u/flk2a)\
**Post date:** [April 7, 2021, 2:20pm UTC](https://forum.flowable.org/t/email-task-recipient-dynamically-defined/7682/3 "2021-04-07T14:20:52Z")

</div>

Hi Martin,

Thank you for your answer. I used the script here : [How to access to user information in script Task - #3 by boneill](https://forum.flowable.org/t/how-to-access-to-user-information-in-script-task/2568/3) and I adapted it to get the email associated to the ID.

Best regards,
