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

How to send email to multiple users with Http request to Sharepoint?

Hi,

What i would like is that if a new item is created in a sharepoint list an email must be sent to certain people.

I have put the email addresses in a variable of the type Array.  And i have put the variable into the Apply to Each.

But i do not know what to do next so i can declare it in the body of the email.

 

PeKi72_0-1647880291320.png

 

I do not want to use other Send Email connectors and i am not authorized to get the sharepoint members. i

just want to get the strings out of the array. 

Gr. P

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @PeKi72,

 

Sorry, I missed the part about the Array variable requirement 😅

 

Below is an example which includes that array variable as well.

 

 

{
"properties":
{"__metadata": {"type":"SP.Utilities.EmailProperties"},
"From":"",
"To": {"results": @{variables('ToAddresses')}},
"CC": {"results": @{variables('CCAddresses')}},
"Body":"Test Body",
"Subject":"Hello World"
}
}

 

 

sendemailwitharrays.png

View solution in original post

9 REPLIES 9
Expiscornovus
Super User
Super User

Hi @PeKi72,

 

Can you try a body like below:

{
"properties":
{"__metadata": {"type":"SP.Utilities.EmailProperties"},
"From":"",
"To": {"results":["jane@contoso.onmicrosoft.com","john@contoso.onmicrosoft.com"]},
"CC": {"results":["tim@contoso.onmicrosoft.com"]},
"Body":"Test Body",
"Subject":"Hello World"
}
}

 

And can you also use these Headers:

{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose"
}

 

Expiscornovus
Super User
Super User

Hi @PeKi72,

 

Sorry, I missed the part about the Array variable requirement 😅

 

Below is an example which includes that array variable as well.

 

 

{
"properties":
{"__metadata": {"type":"SP.Utilities.EmailProperties"},
"From":"",
"To": {"results": @{variables('ToAddresses')}},
"CC": {"results": @{variables('CCAddresses')}},
"Body":"Test Body",
"Subject":"Hello World"
}
}

 

 

sendemailwitharrays.png

PeKi72
Helper III
Helper III

PeKi72_1-1647881646919.png

 

Does not work 

Expiscornovus
Super User
Super User

Hi @PeKi72,

 

Can you change the headers and make sure that both Accept & Content-Type use odata=verbose?

 

Can you also include the metadata in the body and try again?

PeKi72
Helper III
Helper III

I can not choose the variable ToAddresses to put it in the body

PeKi72
Helper III
Helper III

The variable 'ToAddresses' of type 'Array' cannot be initialized or updated with value of type 'String'. The variable 'ToAddresses' only supports values of types 'Array'.

 

PeKi72
Helper III
Helper III

PeKi72_0-1647883253993.png

 

Expiscornovus
Super User
Super User

Hi @PeKi72,

 

If you cannot select the variable from the dynamic content/value list you could alternatively try to use an expression with a variables function instead?

 

Below is a short gif to demonstrate how you could achieve this.

 

Addasexpression.gif

PeKi72
Helper III
Helper III

PeKi72_0-1647884383920.pngPeKi72_1-1647884399979.png

 

Helpful resources

Announcements
Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,642)