Hello,
Does anyone have a quick recipe for sending emails up the food chain using Outlook.Com.SendEmail function?
Here's the code I already have. Just not sure how to add manager and managers manager to the "TO:" area:
'Outlook.com'.SendEmail( Office365Users.MyProfile().Mail, "Subject", emailTemplate.HtmlText, {IsHtml:true} )
Solved! Go to Solution.
Just the users Manager - to all three it might be easier to illustrate in separate calls using variables. Once it's working you can always dump the variables and use a single-line function, but I find the variables helps to make sense of it three weeks later when you're looking at the code again 🙂
So your end result might look something like this (or you can convert it from chained commands to a single line), assuming you want to send to both the manager and manager's manager and cc the user. Obviously you can change this to any combination of To, Cc or Bcc;
UpdateContext({UserManager: Office365Users.Manager(User().Email).Mail}); UpdateContext({ManagerManager: Office365Users.Manager(UserManager).Mail}); Office365.SendEmail(UserManager & ";" & ManagerManager,"Subject",emailTemplate.HtmlText,{IsHtml: true, Cc:User().Email})
Multiple values in To, Cc or Bcc are, like Outlook, separated by semi-colon ";"
Bear in mind, this relies on the Mail property of the Office365Users.Manager() function - if you have different Mail/UPN/Alias values for users it might not find the user- in this case you might want to return instead the managers id property for UserManager and use that to get both his Mail and his managers Mail.
Hope this helps,
RT
Hi @ericonline,
Do you want to send an email to an manager and an manager's manager using Outlook.Com.SendEmail function?
I have made a test on my side, please take a try with the following workaround:
Set the OnSelect property of the "Send Email" button to following formula:
ClearCollect( Recepients, Office365Users.Manager(User().Email).Mail, Office365Users.Manager(Office365Users.Manager(User().Email).Mail).Mail ); 'Outlook.com'.SendEmail(Concat(Recepients,Value&";"),"PowerApps test","This is a test email",{IsHtml:true})
On your side, you should type the following formula:
ClearCollect( Recepients, Office365Users.Manager(User().Email).Mail, Office365Users.Manager(Office365Users.Manager(User().Email).Mail).Mail ); 'Outlook.com'.SendEmail(
Concat(Recepients,Value&";"),
"Subject",
emailTemplate.HtmlText,
{IsHtml:true}
)
Best regards,
Kris
Hi ericonline,
If you want to chain it all together into one command;
Office365.SendEmail(Office365Users.Manager(User().Email).Mail, "Subject", emailTemplate.HtmlText, {IsHtml:true})
Hope this helps,
RT
@RusselThomas, will that send an email to the user, the users manager, and the users managers manager? I'm stuck on that 3rd wrung.
Just the users Manager - to all three it might be easier to illustrate in separate calls using variables. Once it's working you can always dump the variables and use a single-line function, but I find the variables helps to make sense of it three weeks later when you're looking at the code again 🙂
So your end result might look something like this (or you can convert it from chained commands to a single line), assuming you want to send to both the manager and manager's manager and cc the user. Obviously you can change this to any combination of To, Cc or Bcc;
UpdateContext({UserManager: Office365Users.Manager(User().Email).Mail}); UpdateContext({ManagerManager: Office365Users.Manager(UserManager).Mail}); Office365.SendEmail(UserManager & ";" & ManagerManager,"Subject",emailTemplate.HtmlText,{IsHtml: true, Cc:User().Email})
Multiple values in To, Cc or Bcc are, like Outlook, separated by semi-colon ";"
Bear in mind, this relies on the Mail property of the Office365Users.Manager() function - if you have different Mail/UPN/Alias values for users it might not find the user- in this case you might want to return instead the managers id property for UserManager and use that to get both his Mail and his managers Mail.
Hope this helps,
RT
Hi @ericonline,
Do you want to send an email to an manager and an manager's manager using Outlook.Com.SendEmail function?
I have made a test on my side, please take a try with the following workaround:
Set the OnSelect property of the "Send Email" button to following formula:
ClearCollect( Recepients, Office365Users.Manager(User().Email).Mail, Office365Users.Manager(Office365Users.Manager(User().Email).Mail).Mail ); 'Outlook.com'.SendEmail(Concat(Recepients,Value&";"),"PowerApps test","This is a test email",{IsHtml:true})
On your side, you should type the following formula:
ClearCollect( Recepients, Office365Users.Manager(User().Email).Mail, Office365Users.Manager(Office365Users.Manager(User().Email).Mail).Mail ); 'Outlook.com'.SendEmail(
Concat(Recepients,Value&";"),
"Subject",
emailTemplate.HtmlText,
{IsHtml:true}
)
Best regards,
Kris
Hi I can't seem to make this work, even with the semicolons.
This is my code:
Office365.SendEmail(
Label5.Text,
"Welcome",
HtmlText1.HtmlText,
{
Cc: DataCardValue26.Selected.Email;DataCardValue26.Selected.Email,
IsHtml: true
}
)
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
195 | |
45 | |
45 | |
39 | |
35 |
User | Count |
---|---|
269 | |
83 | |
81 | |
73 | |
70 |