# Format List of Items in Email

**URL:** <https://discuss.elastic.co/t/format-list-of-items-in-email/192326>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting\
**Created:** [July 25, 2019, 9:45pm UTC](https://discuss.elastic.co/t/format-list-of-items-in-email/192326 "2019-07-25T21:45:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcarpenter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcarpenter/32/50925_2.png) [@jcarpenter](https://discuss.elastic.co/u/jcarpenter)\
**Post date:** [July 25, 2019, 9:45pm UTC](https://discuss.elastic.co/t/format-list-of-items-in-email/192326/1 "2019-07-25T21:45:25Z")

</div>

I have a list of items retrieved from my query using aggregations. I want to print this list of items in my email with each appearing on a separate line. Right now I can print everything but it all appears one after the other i.e. `file1.txt file2.txt`. I would like for it to appear like

```
file1.txt
file2.txt

```

Below is the action to create the email.

```
"actions": {
	"email_users": {
		"email": {
			"profile": "standard",
			"to": [
				"jcarpenter@mydomain.com"
			],
			"subject": "File Identifier",
			"body": {
				"html": "<p>Files could not be identified due bad receiver id. There were {{ctx.payload.hits.total}} files that could not be identified.</p> <ul><li>{{#ctx.payload.aggregations.file_name.buckets}}{{key}}{{/ctx.payload.aggregations.file_name.buckets}}</li></ul>"
			}
		}
	}

```

Can I print the items this way?

---

<div class="post-metadata">

**Author:** ![jcarpenter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcarpenter/32/50925_2.png) [@jcarpenter](https://discuss.elastic.co/u/jcarpenter)\
**Post date:** [July 26, 2019, 1:41pm UTC](https://discuss.elastic.co/t/format-list-of-items-in-email/192326/2 "2019-07-26T13:41:45Z")

</div>

I was able to format the items using the following command.

```
"actions": {
"email_users": {
  "email": {
	"profile": "standard",
	"to": [
	  "jcarpenter@mydomain.com"
	],
	"subject": "File Identifier",
	"body": {
	  "html": "<p>Files could not be identified due bad receiver id. There were {{ctx.payload.hits.total}} files that could not be identified.</p> <div><ul>{{#ctx.payload.aggregations.file_name.buckets}}{{#key}}<li>{{.}}</li>{{/key}}{{/ctx.payload.aggregations.file_name.buckets}}</ul></div><p>These files have been sent to quarantine.</p>"
	}
  }
}
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 1, 2019, 11:57am UTC](https://discuss.elastic.co/t/format-list-of-items-in-email/192326/3 "2019-08-01T11:57:50Z")

</div>

looks good. I think you could just go with `<li>{{key}}</li>` as well on top of my head!

--Alex

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 29, 2019, 11:57am UTC](https://discuss.elastic.co/t/format-list-of-items-in-email/192326/4 "2019-08-29T11:57:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
