Recently I was asked to provide an example for how to extract email addresses from a RichTextEditor component in a Canvas App.
The extraction would be two fold:
- Extract the email addresses to a Collection
- Concatenate the email addresses into a comma separated string.
The setup of the Canvas App consisted of the following components.
- RichTextEditor to capture the text where email addresses would be extracted from.
- Button to handle the extraction.
- Gallery to display a list of the email addresses found.
- Label to display the email addresses in a comma separated format.
It was pretty easy to setup, where I started to run into challenges was then I was using the MatchAll
to extract the email addresses.
At first I started with using the Predefined Patterns for the email address, Match.Email
. But that did not work.
I kept getting no matches.
After some head scratching, and maybe a little head banging, I switched to a different pattern, "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}"
.
Once I made that change, I began to find matches!
I populated the email addresses into a Collection called Emails
and concatenated the email address into a Variable called EmailsAsString
. One thing to call out with the concatenation, it added a comma at the end, which I removed with a combination of Left
and Len
functions.
Sometimes I get frustrated with how difficult somethings are to do in the Power Platform, but not today! Other than the pattern issue, this was super easy to implement!
Download the sample app at EmailParseCanvasApp_20230824092138.zip.
Discover more from Matt Ruma
Subscribe to get the latest posts sent to your email.