cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IzzyWizz
Resolver I
Resolver I

Send email to a recipient chosen in a Dropdown where the email address is held in a collection along with the recipient's name

Hi,

In the OnStart function of my Sign in Visitors app, I use Clear Collect to set up a table with Name and Email address, e.g.

ClearCollect(AuthorisationList,
     {Name:"A", Email:"xx"}, 
     {Name:"B", Email:"xx"}, 
     {Name:"C", Email:"xx"}
     )

I use this collection for the Items in a dropdown:

AuthorisationList.Name

 What I now want to do is send an email to the person who's name is chosen in the dropdown. But, I don't know how to pull the email address out of the collection when it is the Name that is chosen in the dropdown. I have tried the below but that doesn't work.

Set(
        varEmailSend,
        Office365Outlook.SendEmail(
            Dropdown1.Selected.Email,
            "Visitor Registration",
            "You have just authorised " && TextInputName.Text && " from " && TextInputComp.Text && " as a visitor."
        )
    
);

Can anyone help, please?

Thanks,

Izzy.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@IzzyWizz 

You are restricting the values in your dropdown to the Name only.

Consider the following changes:

On your Dropdown - set the Items property to : AuthorisationList  and then make sure the Value to display is set to Name (this is done easily in the property pane on the right of the designer).

Next, Set your other formula to the following:

Office365Outlook.SendEmailV2(
    Dropdown1.Selected.Email,
    "Visitor Registration",
    "You have just authorised " && TextInputName.Text && " from " && TextInputComp.Text && " as a visitor."
)

Note: SendEmailV2 should be used as SendEmail has been deprecated.  Also, the SendEmailV2 does not return anything, so setting it to a variable is of no value.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@IzzyWizz 

You are restricting the values in your dropdown to the Name only.

Consider the following changes:

On your Dropdown - set the Items property to : AuthorisationList  and then make sure the Value to display is set to Name (this is done easily in the property pane on the right of the designer).

Next, Set your other formula to the following:

Office365Outlook.SendEmailV2(
    Dropdown1.Selected.Email,
    "Visitor Registration",
    "You have just authorised " && TextInputName.Text && " from " && TextInputComp.Text && " as a visitor."
)

Note: SendEmailV2 should be used as SendEmail has been deprecated.  Also, the SendEmailV2 does not return anything, so setting it to a variable is of no value.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
JR-BejeweledOne
Super User
Super User

I would use a variable in the email formula.

 

Set your variable in the onChange formula of the dropdown.   Like this:

 

Set(varEmailAddress, Dropdown1.email)



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

Hi,

Excellent, works perfectly, thanks.

Izzy.

RandyHayes
Super User
Super User

@JR-BejeweledOne 

There is no need for a variable...the information is already there.  It just needs to be referenced.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,090)