web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using 'Outlook.com'.Se...
Power Apps
Unanswered

Using 'Outlook.com'.SendEmail to send email to manager and managers manager

(0) ShareShare
ReportReport
Posted on by

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}
)
Categories:
I have the same question (0)
  • RusselThomas Profile Picture
    4,014 on at

    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

  • Community Power Platform Member Profile Picture
    on at

    @RusselThomas, will that send an email to the user, the users manager, and the users managers manager? I'm stuck on that 3rd wrung. 

  • Verified answer
    RusselThomas Profile Picture
    4,014 on at

    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

     

     

  • Verified answer
    v-xida-msft Profile Picture
    on at

    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:2.JPG

     

     

    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

     

  • Community Power Platform Member Profile Picture
    on at

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard