cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

Generate HTML Code from Outlook

Hello Matthew,

 

Thank you for your recent blog post on how to generate HTML code from Outlook. 

https://matthewdevaney.com/send-formatted-emails-from-power-apps-without-writing-any-html-code/

 

I have given it a try, but even a simple 3 bullet point list generates almost 800 lines of HTML code so I'm wondering if you can help me figure out what I am doing wrong. I'm attaching a snapshot of the simple bullet list and the html in pdf format since we can't post htm files on the forum. I've tried using both my corporate and personal Outlook accounts in case that would make a difference, but it hasn't. Any other ideas of what I could try?

 

Thank you,

Teresa 

3 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted

@tagustin2020 

Ah...the date...okay, adjust to the following:

Office365Outlook.SendEmailV2("teresa.agustin@tektronix.com",
    "New Tool Support Request Notification",
    Substitute(
        Substitute(
            Substitute(
                Substitute(
                    Substitute(HtmlEmail.HtmlText, 
                        "<recordID>", Text(frmNewRequest.LastSubmit.ID)),
                    "<fullName>", frmNewRequest.LastSubmit.'Created By'.DisplayName),
                "<requestTitle>", frmNewRequest.LastSubmit.'Request Summary Title'),
            "<description>", frmNewRequest.LastSubmit.Description),
        "<neededBy>", Text(frmNewRequest.LastSubmit.NeededBy, ShortDate)
    )
);
Set(HighlightRecord, frmNewRequest.LastSubmit);
ResetForm(frmNewRequest);

Navigate(HomeScreen, Transition.None);

Also a little adjustment for the ID in that formula.

 

See where that goes.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Highlighted

@tagustin2020 

Close....you can send to multiple emails in the SendEmailV2 function, they just need to be semicolon separated. So, change the line in your formula to the following:

Office365Outlook.SendEmailV2("teresa.agustin@tektronix.com;" & varUser.Email,

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Highlighted

Thank you for the prompt reply Randy, that worked! I'll mark this and your other "substitute" formula as solutions. I'm attaching a Word doc detailing other aspects of how I got this working in case anyone who comes across this post wishes to view it.

View solution in original post

19 REPLIES 19
Highlighted
Super User III
Super User III

@tagustin2020 

Hi Teresa,

 

You mention that the html is 800 lines long...my question though is - are you stating that you get the HTML *with* the three bullet points correctly and it is 800 lines of html long, or that your 3 bullet points is 800 bullet points?

 

If you followed Matt's suggestion by saving the HTML from an Email, that will usually have extensive amounts of html markup in it for all the styling that comes along for the ride with an Outlook Email.  If you are comfortable with the Html, you can strip out what you don't need and slim it down.

 

I hope this is what you might be looking for...if not, please expand and clarify.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted

Outlook and Word mangle the HTML and generate tons of CSS and other directives.  When I create email templates I create them manually with inline CSS.  When you send HTML email in Outlook it will mangle HTML but sends just fine.    I'm currently using Web Expression 4 (free) which is a discontinued MS product.  It does support HTML5 and CSS3.  You can set it to generate inline CSS.  I've used it for years.  This is test HTML sent with Outlook

 

 

<div style="font-size: 12pt; font-family: Arial, Tahoma, Geneva, Verdana, sans-serif;">
	<ul>
		<li>Bullet 1</li>
		<li>Bullet 2</li>
		<li>Bullet 2</li>
	</ul>
</div>

 

This is HTML email received in Outlook.

 

<head>
<style type="text/css">

ul
	{margin-bottom:0in;}
 li.MsoNormal
	{margin:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	}
 p.MsoNormal
	{margin:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	}
</style>
</head>

<ul type="disc">
	<li class="MsoNormal" style="color:black;mso-margin-top-alt:auto;mso-margin-bottom-alt:
     auto;mso-list:l0 level1 lfo1;tab-stops:list .5in">
	<span style="font-size:
     12.0pt;font-family:&quot;Arial&quot;,sans-serif;mso-fareast-font-family:&quot;Times New Roman&quot;">
	Bullet 1<o:p></o:p></span></li>
	<li class="MsoNormal" style="color:black;mso-margin-top-alt:auto;mso-margin-bottom-alt:
     auto;mso-list:l0 level1 lfo1;tab-stops:list .5in">
	<span style="font-size:
     12.0pt;font-family:&quot;Arial&quot;,sans-serif;mso-fareast-font-family:&quot;Times New Roman&quot;">
	Bullet 2<o:p></o:p></span></li>
	<li class="MsoNormal" style="color:black;mso-margin-top-alt:auto;mso-margin-bottom-alt:
     auto;mso-list:l0 level1 lfo1;tab-stops:list .5in">
	<span style="font-size:
     12.0pt;font-family:&quot;Arial&quot;,sans-serif;mso-fareast-font-family:&quot;Times New Roman&quot;">
	Bullet 2<o:p></o:p></span></li>
</ul>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

 

Highlighted

@RandyHayes 

 

Hi Randy,

 

I'm pretty comfortable with HTML (still learning CSS). I got the email dialed in to how I want it to look, but wanted to pick your brain about our old friends varRecord and last submit. 

 

Here is the OnSelect formula for my new form submit button. Matthew recommends setting up a variable (see blue text) to store the HtmlText although I'm not sure why as I don't think I have seen others do that in their tutorials.

 

Set(varPlaySpinner,true);SubmitForm(frmNewRequest);Set(HighlightRecord, LookUp('Tool Design Support Requests', ID = frmNewRequest.LastSubmit.ID));Set(varEmailNotification,HtmlEmail.HtmlText);Navigate(HomeScreen,Transition.None);ResetForm(frmNewRequest);Set(varPlaySpinner,false)

 

Here is my new form OnSuccess formula with the variable referenced at the end.

Office365Outlook.SendEmailV2("teresa.agustin@tektronix.com","New Tool Support Request Notification",varEmailNotification)

 

There are a couple of things going wrong. 

1) The emails aren't coming through right away.  I need to submit a second form to "push" the first email through to my inbox.

2) The link seen in the email screenshot is a deep link to the record, but it is coming through blank. I tried to follow the HighlightRecord last submit syntax (the one that highlights the last submitted item in the gallery), but I can't seem to write it correctly.

 

If you have a moment, can you help me out? I'm not sure if my HTML Word doc attached correctly so if not, here is the portion of HTML that contains the varRecord link. This is the link that is sent via email when the project status changes so it is confirmed to be working.

 

<h2>Tool Design Support Request Details</h2>

<p>The following request was submitted today. Click here to <a href='https://apps.powerapps.com/play/guid/tenantID&hidenavbar=true&ProjectID=

"& varRecord.ID & "'>view the record</a> in more detail.</p>

 

<table>

  <tr>

    <th>Query</th>

    <th>Response</th>

  </tr>

<tr><td>Requestor</td><td>"&varUser.FullName&"</td></tr>

<tr><td>Request Title</td><td>"&txtTitleNew.Text&"</td></tr>

<tr><td>Description</td><td>"&txtDescriptionNew.Text&"</td></tr>

<tr><td>Needed By Date</td><td>"&calNeededBy.SelectedDate&"</td></tr>

</table>

 

Thank you, 

Teresa

Highlighted

@mogulman 

 

Thank you for the suggestion. I will check out that tool.

 

teresa

Highlighted

@tagustin2020 

There are a lot of ways to go about this.  I will suggest the method that I use often (well somewhat).  I say somewhat because I typically don't like to "hard code" the email template into the App, I will usually put that in a SharePoint list where it can be altered without altering the app, but sometimes, right in the app is sufficient.

And, when I do that, here is how I go about it.

I will have a screen (usually not accessible by users) that has an HTML Text control in it so that I can "see" the HTML as I put the HTML tags in.

 

So, if we have an HTML text control, I would set the HtmlText property to the following:

<h2>Tool Design Support Request Details</h2>
<p>The following request was submitted today. Click here to <a href='https://apps.powerapps.com/play/guid/tenantID&hidenavbar=true&ProjectID=<recordID>'>view the record</a> in more detail.</p>
<table>
  <tr>
    <th>Query</th>
    <th>Response</th>
  </tr>
  <tr>
     <td>Requestor</td>
     <td><fullName></td>
  </tr>
  <tr>
     <td>Request Title</td>
     <td><requestTitle></td>
  </tr>
  <tr>
      <td>Description</td>
      <td><description></td>
  </tr>

  <tr>
      <td>Needed By Date</td>
      <td><neededBy></td>
  </tr>
</table>

 

To get the information in that you want, I look to the substitute process. (Note: this is about the limit of the substitutes that I would personally use before moving the entire html into the OnSuccess formula)

OnSuccess:

Office365Outlook.SendEmailV2("teresa.agustin@tektronix.com",
    "New Tool Support Request Notification",
    Substitute(
        Substitute(
            Substitute(
                Substitute(
                    Substitute(HtmlEmail.HtmlText, 
                        "<recordID>", frmNewRequest.LastSubmit.ID),
                    "<fullName>", frmNewRequest.LastSubmit.Requestor),
                "<requestTitle>", frmNewRequest.LastSubmit.Title),
            "<description>", frmNewRequest.LastSubmit.Description),
        "<neededBy>", frmNewRequest.LastSubmit.NeededBy
    )
);
Set(HighlightRecord, frmNewRequest.LastSubmit);
ResetForm(frmNewRequest);

Navigate(HomeScreen, Transition.None);

 

Your Submit button OnSelect formula should be:

Set(varPlaySpinner,true);
SubmitForm(frmNewRequest);
Set(varPlaySpinner,false)

 

Your original HTML referred to controls on the screen that may or may not have the correct values in them after you submit, with the above method, we are dealing with the actual values submitted and substituting them into the HTML template.  (Note, I guesses on some of the column names above, so replace as appropriate from your datasource).

 

If the form submits successfully, you should see the email pretty quick in your inbox.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted

Hello Randy,

 

Thank you for this suggestion. I'm try. I can't get this to work yet so I want to be sure I am clear. In the HTMLText control formula, are <fullName>, <requestTitle>, <description>, <neededBy> variables or are they supposed to be the actual names of my SharePoint columns?

 

In the OnSuccess formula, (frmNewRequest.LastSubmit.Title -to choose just one example) am I supposed to reference the internal name of the SharePoint column or the display name? Title doesn't come up in Intellisense and when I use the display name of the column 'Request Summary Title' I still get red squigglies. Same for all for the other columns.

 

Thank you,

Teresa

Highlighted

@tagustin2020 

No, the HTML needs no adjustment.  Leave as-is.

The only adjustments necessary would have been on the 5 LastSubmit statements to make sure they had the correct column names.  I know ID is okay, but wasn't sure of your columns names for Requestor, Title, Description and NeededBy.

They should all match what "intellisense" (tip my hat to the developer side of you) shows.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted

Hi Randy,

 

To follow-up on my last note, I wasn't having any trouble in regards to the correct field values not coming through (I ran over 30 tests), they were just delayed, they weren't coming through in real time. I always had to submit a second form to push them through. Not sure if that makes a difference to your advice.

 

Teresa

Highlighted

@tagustin2020 

My concern, and thus reason for changing the way you were doing that, was that I could not be assured that the controls you were referencing would have the last submitted values in.  I knew that this method would.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (12,993)