Hi, and, thanks for watching the video. This is Todd Baginski. I'm a Microsoft MVP
and Partner and CTO of Canviz Consulting.
And, this video I'm going to give you a deep dive
in PowerApps and I'm going to show you inside of the Estimator Pro PowerApps
sample template - how you can create dynamic email templates inside of
a PowerApp. The Estimator Pro sample template allows you
to create estimates for different projects you may have an email those estimates
to potential or current customers. If you wish to learn more about this PowerApp, I
suggest you look at the deep dive video that I have for this PowerApp as
well as the installation instructions and the video which gives you an
end-to-end walk through the functionality. So in the interest of time, in this video
since I'm just showing you how to
create a dynamic email template in a PowerApp, I've already populated this PowerApp
with information as well as attachment of a picture, a sketch,
a couple different products, and a lot of information. So now what I'd like to do is I'd
actually like to send this estimate to someone and when I
click send here it's going to send-me email with all the information we saw in the previous page
to this recipient I can add more than one here for like with this
e-mail subject and this message. So I'm going to click send now
that actually send an email off and
now that's done in the app I can create another estimate if I'd like.
Now that the email has been sent, I can open up and here's what it looks like. You
can see the information we had in there before as well as the attachment
the picture I took and also the sketch that was drawn
in the app. So I'm going to dig into the app now and show you exactly how
we were able to templatize this information and create dynamic
email templates inside the PowerApp. So now I've returned to the page where I actually
sent the email and as I mentioned many of the videos that I've done for these different PowerApps
we created, my favorite way
to really learn how a PowerApp is working and dig into it is to play it inside
of the editor like I'm doing here and preview mode and then take it out a
preview mode which allows me to inspect controls and I can dig
right into the control here by clicking on the send button really see what's
happening here under the hood. So if you're ever work in with a PowerApp
and you want to figure out how it works I suggest you follow the same process here.
So, there's more than one way you can actually go about creating templated
pieces when you'd like to do exports to various places like
email or OneNote in a PowerApp. The pattern
that I'm showing here is one way to do it another pattern you can use you
can actually find in the Meeting Capture app if you watch my deep dive video on
how to export to OneNote, w'ere also creating html.
and sending things in email. There we use a different pattern
that for creating dynamic template based exports in PowerApps so you can
check out that pattern as well but this pattern is a little bit more simple. This pattern
essentially is going to generate some html.
In a context variable we call
email html right here.
the way this works is at the top of the page we create a bunch of different collections
that tells us which products their names the prices all kinds of
information and metadata about the current quote that's being built in the app
and it gives us all that information right here so that we can use inside of
our template. So our email html is essentially a
string.
That you can see here is html.
And, we've even baked in the css here so we can style it make sure
it's always available for us and you'll notice here
we've just got the html that's going to create
the email so whatever we want to put something dynamic into that email,
for example, the subject.
That's where we grab that variable.
And, then we can also even look at the first item in the order
detail collection order date and convert that to text,
for example, and, then here's our format that we're
going to format that within so.
The text function is being applied with this format to the order
date coming out of this first item in this collection which then puts
the order date inside e-mail as well. So whatever as you can see PowerApp
functions you'd like to use that your data you have full control over here. It's a
lot like doing things inside of a razor page ASP.NET or something like that.
You can see several different places in here where our data is
dynamic and then one interesting spot is right here
in the products section. So as we look
at the email that we have.
It looks like this so here is
product one in product two. You can see we have count of tow of them in the
product section here and this is essentially
using concatenation functions and different values
out of the data that we have PowerApps to test where we're adding that collection and render
the html appropriately so we can actually stack things one after another.
When we're all done creating our html,
That ends right here at this line.
So, here
is the actual code that actually
sends the email. So if someone is selected,
the check box that says send the current person a copy,
then we would fall down into this category if they said don't
send the current person copy though we're in this category.
The only difference is we add the cc with the current users
mail when we send carbon copy and copy the occur user
on it. The important things to point out about actually sending the email
here is if we look at the third argument. Here's the body and the send
email call to the Office 365 Outlook connector notice this is the
email html context variable that we built up in the code just
above this.
And, then the other key piece of the puzzle is html.
We have that set the true because we are using html to format
the email to make it look really nice here. If you're not using html and
you can still templatize things
just in plain-text and then just set this to false. So as you can see
it's very easy to go about creating an email template and as I
mentioned there's other places and patterns where you can actually store this template and
inject data into it. So I encourage you to check out the Meeting Capture video
where it demonstrates how to store those templates in other places outside of
the PowerApp so you don't actually have to update the template inside
of the PowerApp here if you'd like to change it. Hope this technique comes in handy for you and you
enjoy the PoewrApp. Thanks for watching the video and I'll see you next time.