Can I use {{#lookupissues}} in the "to" of an email
Asked by Tim Foster:

I am trying to send an automated email to the reporters of issues when we release into production. I have the email aspect working nicely when it sends to my email address. I am able to list the epics included in the release by defining a lookup JQL statement.

The body works fine to display the URLs for the epics included in the release. Since my JQL is defined before my email component, and my email component can access the epics without a problem, I can't understand where I'm going wrong with referencing the same smartvalue in the "to" for my email.

My "to" looks like {{#lookupIssues}}{{Reporter}};{{/}} but I get the error:

*Could not send email, the 'To' address field is empty. If you have referenced a field it may be empty.*

The Reporter field isn't empty, (it's me in this test), so could someone point me in the right direction please?


Answers:
author: Mykenna Cepek
body: To help troubleshoot rules, I always like to use the "Audit log" action - in this case to see what your lookupissues smart value expression evaluates to.

In my test, it looks like this:

![Screen Shot 2022-01-28 at 11.32.45 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/180532iE598B2D67F7AC764/image-size/large?v=v2&px=999 "Screen Shot 2022-01-28 at 11.32.45 AM.png")

I'm guessing that's not quite what you expected (it's not an email address). It's actually the user ID, which is what Atlassian uses to identify users.

As noted [here](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-users/), you probably want to write something like **reporter.emailAddress** instead.

Additionally, you might find problems with the trailing ; character. Remove that in your early testing when there is just one email, to confirm that everything else works in that simple case.

Then you may have to experiment with what works (comma instead of semicolon perhaps?) to support multiple emails. Reference [this documentation](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/) if you find a need to use separator characters between email addresses but omit the last one.

comments: author: Bill Sheboy
body: Hi [@Tim Foster](/t5/user/viewprofilepage/user-id/4721333) -- Welcome to the Atlassian Community!

Yes, and...to the other responses: You may be getting an issue from any trailing delimiters, so you can selectively add the delimiter like this:

```
{{#lookupIssues}}{{reporter.emailAddress}}{{^last}};{{/}}{{/}}
```

This will add a semicolon between all the addresses, and leave off the last one.

Kind regards,  
Bill


author: Tim Foster
body: Thank you, all of you, for your help. However, I am still not able to get this working correctly.

I have added a Log Action: {{#LookupIssues}}{{reporter.emailAddress}}{{/}} but it displays nothing. I have tried changing this to: {{#LookupIssues}}{{key}}{{/}} but still it displays nothing. The action details shows:

##### Log action {#toc-hId-2013735719}

Log  
But with nothing else. In the Associated Items box I can see that LookupIssues finds the correct Jira, and following this url takes me to the correct place. I can see that I am the reporter (and assignee) so all good there. Just no email.  
My "To" for the email is identical to the one given by Bill above;  

```
{{#lookupIssues}}{{reporter.emailAddress}}{{^last}};{{/}}{{/}}
```

But still no email.  
I'm tearing my hair out with this :(


author: Mykenna Cepek
body: Hmm, actual screenshots of your rule and the components of interest might help. At this point, all I can say is "works on my box" (works in my cloud?). See below.

![Screen Shot 2022-01-31 at 10.25.59 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/180821iFAA1F20CAC6FC886/image-size/large?v=v2&px=999 "Screen Shot 2022-01-31 at 10.25.59 AM.png")


author: Tim Perrault
body: [@Mykenna Cepek](/t5/user/viewprofilepage/user-id/3527113)since his JQL returns multiple issues would that cause a problem or would automation just loop through all the issues?


author: Bill Sheboy
body: Yes, and...smart values are usually case-sensitive. So please check if you are using {{lookupIssues}} in your log entries and the email TO address list. Thanks!


author: Mykenna Cepek
body: [@Tim Perrault](/t5/user/viewprofilepage/user-id/165835) The rule I shared above works fine with multiple issues/emails. I just tested it.

It is unfortunate that the same email may be repeated multiple times. But the effort in Automation to de-duplicate a list would be best handled in a separate post.


author: Tim Perrault
body: [@Mykenna Cepek](/t5/user/viewprofilepage/user-id/3527113)awesome! Wasn't sure about that. Thanks for checking :)


author: Tim Foster
body: The jql I'm using only returns 1 task for this test. It could, and probably would include more (if I ever get it working!), but the test is only using one.

Everything else in the automation seems good. If I add my hardcoded email into the "to" I get the email with the jira(s) linked nicely, but I'm the only one in the list. I'd be happy if I got mutiple emails for being the reporter and hardcoded at this stage :)


author: Bill Sheboy
body: Mykenna, did you try to actually send the emails? I just tested and it failed for me too:

* Can write the values to the audit log, but they collapse to null in the email TO field
* Tried saving the Lookup Issue values to a single created variable first, and got the same result
* Tried a separate branch to send to one issue's reporter with {{issue.reporter.emailAddress}} and that worked

It appears there is a problem with Send Email and use of smart values which are not in one issue.

[@Tim Foster](/t5/user/viewprofilepage/user-id/4721333) ...I suggest it may be time to submit a ticket to Atlassian support for this one: <https://support.atlassian.com/contact/#/>


author: Mykenna Cepek
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) I did not try to actually send emails.

[@Tim Foster](/t5/user/viewprofilepage/user-id/4721333) wasn't even able to get results from the dead-simple Log Action, and I saw no need to go further until he was able to get that to work.

There may be issues with the separator character (semicolon, comma, etc), which I mentioned previously. Again, seemed premature with no actual smart value output.


author: Mark Segall
body: Hi [@Tim Foster](/t5/user/viewprofilepage/user-id/4721333) and welcome to the community. Reporter by itself will bring up the user ID. You want to use this instead:

```
{{reporter.emailAddress}}
```


author: Tim Perrault
body: Hi [@Tim Foster](/t5/user/viewprofilepage/user-id/4721333)

Firstly that's a cool name you got :)

Try using this smart value `{{reporter.emailAddress}}`

Thanks,

Tim

comments: author: Tim Perrault
body: [@Tim Foster](/t5/user/viewprofilepage/user-id/4721333)

Try this smart value and let me know if this works {{issue.reporter.emailAddress}}

I was able to send an email, but my automation is very simple.

![automation.png](https://community.atlassian.com/t5/image/serverpage/image-id/180799i36FE40D74D93FFD7/image-size/large?v=v2&px=999 "automation.png")

Thanks,

Tim


author: Tim Foster
body: Nope, still the same problem. I think I'm going to abandon the idea of the email and just have it post to the Teams/Slack channels instead.

Thanks for your help with this though. I've learned more from these boards, than anywhere else.


author: Tim Perrault
body: Bummer. Are you able to post a screen shot of the steps of your automation? I want to fiddle around with this more on my off time.


author: Tim Foster
body: These are the steps I have. It's not a complex automation by any means

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/180816i68C26EF1BA01CF74/image-dimensions/559x351?v=v2 "image.png")


author: Tim Perrault
body: [@Tim Foster](/t5/user/viewprofilepage/user-id/4721333)Thanks! I'll let you know if I can get something working.


author: Bill Sheboy
body: Hi [@Tim Foster](/t5/user/viewprofilepage/user-id/4721333)

Did you note you have some square brackets, not curly ones in your smart values in the image? The smart values should only use curly brackets.

Thanks,  
Bill


author: Tim Foster
body: I hadn't noticed that, thanks Bill. However, I'm getting the same error after correcting it. I never see the log detail as per the screenshot from [@Mykenna Cepek](/t5/user/viewprofilepage/user-id/3527113) though, so I think something is amiss elsewhere (although that wouldn't have help, so thanks for spotting that)


author: Tim Perrault
body: Wow! Good catch [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) This reminds me when I was connecting to a database one time was using jbdc instead of jdbc :)


author: Ivanna
body: Hi [@Tim Foster](/t5/user/viewprofilepage/user-id/4721333) ,

You can try this,

{{lookupIssues.reporter.emailAddress}}

I success to do this?It will sent email to reporters!

![messageImage_1673324087802.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/233601iFA6F3C2C75935DA1/image-size/large?v=v2&px=999 "messageImage_1673324087802.jpg")![2.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/233602i35E7AF1691072232/image-size/large?v=v2&px=999 "2.jpg")


author: Bill Sheboy
body: Hi [@Ivanna](/t5/user/viewprofilepage/user-id/5095725) -- Welcome to the Atlassian Community!

Context is important for automation rules, so I suspect the reason your reference to just Reporter failed is there is no issue at that rule scope.

If you believe it is something else, please create a new question (rather than adding to this one), posting images of your rule and the complete audit log details of the rule run for context.

Kind regards,  
Bill