How to mail collections

Introduction

To send a mail through a canvas app, you can use the connector Office365Outlook and function SendEmailV2().  

Using this feature to send an email with some text and a fancy image is not necessarily challenging. What I do like to discuss is sending collections in tables.

Data model

In the following example, we are going to talk about questions that candidates can answer. Each answer has a question and an answer. Kiss 🙂

So when we can use our fancy Canvas App to collect data (store users with answers) we want to send all answers from 1 specific user. To do this we are first going to create a collection of all the answers of the selected user.

Now that we have a collection of our responses we can start using them to mail. There are several ways to do this. I am going to discuss some that may be useful.

				
					ForAll(
    Filter(
        Answers,
        UserId = galCandidates.Selected.ID
    ) As Answers,
    Collect(
        colAnswerSelectedCandidate,
        "<p>Question: " &amp; Answers.Question &amp; "</p>&#13;
        <p>Answer: " &amp; Answers.Answer &amp; " </p> <br/>"&#13;
    )&#13;
);
				
			

List

Now we are going to concatenate our collection with the appropriate html tags, this will make each answer a list item.

				
					   Office365Outlook.SendEmailV2(&#13;
    "yniasbensch@live.be",&#13;
    "Overview answers" &amp; galCandidates.Selected.Name,&#13;
&#13;
    "Dear colleague, <br/> <br/>" &amp; &#13;
    "Here you will find a summary of the answers from the requested user.<br/> <br/>" &amp; &#13;
&#13;
    // Answers&#13;
    "<h2>Answers</h2>" &amp; Char(10) &amp;&#13;
    "<ol>" &amp;&#13;
    Concat(colAnswerSelectedCandidate, "<li>" &amp; Value,"</li>") &amp;  Char(10) &amp; Char(10) &amp;&#13;
    "</ol>"&#13;
    );
				
			

This gives the following result:

Table

Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.
				
					   Office365Outlook.SendEmailV2(&#13;
    "yniasbensch@live.be",&#13;
    "Overview answers" &amp; galCandidates.Selected.Name,&#13;
&#13;
    "Dear colleague, <br/> <br/>" &amp; &#13;
    "Here you will find a summary of the answers from the requested user.<br/> <br/>" &amp; &#13;
    &#13;
    // Answers&#13;
    "&#13;
&#13;
&#13;
    " & Char(10) &
    "
    " & Concat(colAnswerSelectedCandidate, "
" & Value,"") & Char(10) & Char(10) & "

Answers

" );

This gives the following result:

Related posts

Cloud flow with filter rows not triggered

How to provide additional logging in your Canvas App

How to open a specific screen in a Canvas App