# Send email of a task with comments

**URL:** <https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108>\
**Category:** Open Discussions\
**Created:** [January 15, 2019, 10:41am UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108 "2019-01-15T10:41:31Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![etalasquera](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@etalasquera](https://kanboard.discourse.group/u/etalasquera)\
**Post date:** [January 15, 2019, 10:41am UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/1 "2019-01-15T10:41:31Z")

</div>

Hi folks!

There is a way to send email of a finished task including all comments on that task?

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [January 15, 2019, 2:10pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/2 "2019-01-15T14:10:35Z")

</div>

not out of the box.

you could:  
1.) add an automatic action that does it for you  
[https://docs.kanboard.org/en/latest/plugins/automatic\_actions.html](https://docs.kanboard.org/en/latest/plugins/automatic_actions.html)

or

2.) override the notification template for the appropriate event (i.e. task close), with your own template to include all the comments.  
[https://docs.kanboard.org/en/latest/plugins/overrides.html](https://docs.kanboard.org/en/latest/plugins/overrides.html)

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [September 16, 2022, 3:43am UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/3 "2022-09-16T03:43:35Z")

</div>

Hello, did you manage to find a solution for this?

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [September 16, 2022, 11:15am UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/4 "2022-09-16T11:15:54Z")

</div>

which part cant you figure out?

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [September 16, 2022, 12:38pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/5 "2022-09-16T12:38:38Z")

</div>

> <https://github.com/creecros/SendEmailCreator/blob/master/Action/SendTaskComment.php>

This action sends and email whenever there is a “New Comment” on a task.  
I would think it should give you a good baseline to figure out how to send “All comments” when a task is closed.

If you can’t figure it out, let me know.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [September 16, 2022, 1:26pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/6 "2022-09-16T13:26:03Z")

</div>

I will look at it again, Im just getting confused with how to create the action to send an email so that when the task closes, besides sending an email to comment that the task is closed… another email is fired through actions to send the ‘summary’ of the closed task… e.g. description and full comment history.

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [September 16, 2022, 1:31pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/7 "2022-09-16T13:31:32Z")

</div>

so do you want 1 email upon task close, with all comments and descriptions, or do you want 2 emails?

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [September 16, 2022, 1:33pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/8 "2022-09-16T13:33:43Z")

</div>

I already get an email that a task is closed… through an action…  
I need a seperate email with a subject (Task summary) which will consist of the task description with a full history of the comments.

So for this board i would get 2 emails, but for other boards it would depend on which actions i use for that board.

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [September 16, 2022, 1:46pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/9 "2022-09-16T13:46:16Z")

</div>

ya that should be pretty simple.

get as far as you can, and then either add me to the repo or send me the code, and i will complete it.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [October 16, 2022, 8:57pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/10 "2022-10-16T20:57:23Z")

</div>

am I right or wrong in saying that the only thing to change (in a duplicate file of course) would be:

```auto
$this->template->render('commen/show', array(
                            'task' => $data['task'],
                            'comment' => $data['comment'],
                        ))

```

this wouldďsend ALL the task comments… then to add the description it would be to add `'description' => $data['description'],` to the array?

Or have I got it all wrong?

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [October 16, 2022, 11:04pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/11 "2022-10-16T23:04:39Z")

</div>

that would be a negative. you want to send all comments, the current action i wrote, is based on when a new comment is created, i.e. the event. That event only carries the data for that comment, its also not your event, that you want. your event is on task close. `TaskModel::EVENT_CLOSE`

you need to look at a controller that sends data to “comment/show” template, see how they handle that. Probably the TaskViewController, is where that is going to start, and then follow the code until you find exactly what to send to the “comment/show” template, and whether or not you need any iterations, may already be handled with the iterations.

you can see here the beginning of the comment data coming to fruition.

> <https://github.com/kanboard/kanboard/blob/0b8a270bbb9179c14b73fabc3853f698a21775e5/app/Controller/TaskViewController.php#L72>

it actually sends the data to “task\_comment/show” next, id follow suit if i were you.

> <https://github.com/kanboard/kanboard/blob/0b8a270bbb9179c14b73fabc3853f698a21775e5/app/Template/task/show.php#L46-52>

from there it takes care of all the iterations for you.

> <https://github.com/kanboard/kanboard/blob/0b8a270bbb9179c14b73fabc3853f698a21775e5/app/Template/task_comments/show.php#L14-22>

it might seem complicated, but its actually simple, send the exact same data, to the “task\_comment/show” template, and then all the comments will be rendered in your email.

the above gives you all the information you need to do that, how to get the data(mostly found in the controller using the $task variable which you have, for $editable just use false), and what to send after you got it(found in the “task/show” template, which sends 4 variables on lines 47-50, you need them all).

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [October 18, 2022, 7:13pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/12 "2022-10-18T19:13:02Z")

</div>

thank you so much forŕthe detailed explanation… I have tried my best to understand it with my basic skills…

Please check the code for me here: [GitHub - aljawaid/KanboardEmailHistory](https://github.com/aljawaid/KanboardEmailHistory)

I’m trying to create an action so that:  
when the task closes:

1. a comment is added to the task to say that the task history including comments was sent to xyz.
2. the task description is in the body of the email, followed by the full task history.

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [October 18, 2022, 10:29pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/13 "2022-10-18T22:29:51Z")

</div>

I fixed what you had, but did not add any features. If you need more help, again, try and let me know when stuck.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [October 18, 2022, 10:55pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/14 "2022-10-18T22:55:36Z")

</div>

woah thanks foŕthis… I had a glance, will test when I get home… it seems I was way out lol

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [October 19, 2022, 12:41am UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/15 "2022-10-19T00:41:19Z")

</div>

thats good, because i didnt test it. i see one thing i missed, forgot to add projectmodel in the “use” section.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [October 20, 2022, 3:47pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/16 "2022-10-20T15:47:30Z")

</div>

Can you please review my changes? I missed the description, but I think I have fully done it now. I just need you to have a glance at it as you understand the code for Kanboard a lot better than me.

---

<div class="post-metadata">

**Author:** ![creecros](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/creecros/32/156_2.png) [@creecros](https://kanboard.discourse.group/u/creecros)\
**Post date:** [October 20, 2022, 4:34pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/17 "2022-10-20T16:34:57Z")

</div>

glanced.

commented on your changes. it will need a lot of fixes.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/aljawaid/32/1090_2.png) [@aljawaid](https://kanboard.discourse.group/u/aljawaid)\
**Post date:** [October 20, 2022, 8:05pm UTC](https://kanboard.discourse.group/t/send-email-of-a-task-with-comments/108/18 "2022-10-20T20:05:12Z")

</div>

I’ve got it working and released the first version. Hope it’s useful to others too.

> **[GitHub - aljawaid/KanboardEmailHistory: This action plugin adds a new action...](https://github.com/aljawaid/KanboardEmailHistory)**
>
> This action plugin adds a new action to the Kanboard user workflow process. - GitHub - aljawaid/KanboardEmailHistory: This action plugin adds a new action to the Kanboard user workflow process.
