cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IzzyWizz
Helper III
Helper III

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 III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

4 REPLIES 4
RandyHayes
Super User III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

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 III
Super User III

@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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (59,598)