cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PeKi72
Post Patron
Post Patron

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



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


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"
}

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


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



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


PeKi72
Post Patron
Post Patron

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?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


PeKi72
Post Patron
Post Patron

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

PeKi72
Post Patron
Post Patron

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
Post Patron
Post Patron

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



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


PeKi72
Post Patron
Post Patron

PeKi72_0-1647884383920.pngPeKi72_1-1647884399979.png

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,875)