Friday, October 1, 2021

Power Automate: Send Mail With Other Account

 Hello Friends,

Welcome back with another post on Power Automate. Couple of days back, one interviewer asked me if we can send mail from Power Automate using mail account other than the creator of that Power Automate. I was not sure about that therefore I said that I don't know but as per my assumption, the person should be added as co-owner. 😞

Later on, I tried to find out if this could be possible. Surprisingly, I was correct but the answer was not complete. Because, first of all, the user should be co-owner. After then, in Connections, we have to switch the connection of outlook with that user's account connection. Let's try-

  1. First of all, create a simple list in SharePoint. I have created with name "SendOtherMail" having the default "Title" column.
  2. Now click on App Launcher (9 dots at top left corner) and click on Power Automate link.
  3. It will open the Power Automate portal. Click on + Create.
  4. Choose Automated cloud flow. Then provide a suitable name to the flow and choose trigger as When an item is created (SharePoint). Click on Create.
  5. It will create the flow and then ask you to choose the Site address and list name upon which it will work.
  6. Now add a step "Send an email (V2) Office 365 Outlook".
  7. Provide the input to the fields- "To", "Subject", "Body".
  8. If we execute the flow now, it will send email with the current owner capacity. But we want to send email from other account. So, we will save this flow as of now and will come back to it's details page by clicking on back arrow.
  9. Now click on Edit link of Owners section (#1 in below screenshot) to add a new co-owner.
  10. Search the new co-owner and add it.
  11. Then click on Manage Connections link in the Embedded connections section.
  12. It will load a page where all currently active connections will be displayed.
  13. If the added co-owner's outlook connection is getting displayed then click on ellipses (3 dots) ahead to that connection and choose Switch account. Otherwise click on + New connection link provided at the top and then choose Office 365 Outlook >> Create.
  14. It will the login credentials (Pick an account). Ask the user to provide credentials to create the connection.
  15. Once the connection get established, come back to the connections list.
  16. Look for the connection recently added and click on ellipses ahead of that connection. Choose Switch account from the popup list. When you click on Switch account, it will again show a popup where login accounts will be displayed. Choose the other user account.
  17. This way, outlook account has been switched.
  18. Now click on My flows >> Shared with me. As the flow has been shared with other user therefore, it will now appear in Shared with me tab.
  19. Click on the flow name and click on Edit.
  20. Expand the Send an Email action. Click on Show advanced options.
  21. Fill in the other user's email in From (Send as) input box and now Save the flow.
  22. Flow is now ready.
  23. Add an item in SharePoint list.
  24. Come back to Power Automate and check the Run history.
  25. As it can be seen that the flow has executed successfully.
  26. Now check the mail box.
  27. Hurray! The mail is received from other user's account. Now, if you ask the user to check his/her Sent Items in Outlook, he/she will find that the mail is reflecting in his/her Sent Items.
  28. This way, we can achieve this functionality.
With this, I am concluding this post.
Happy Coding !!!
Will see you again with some new topics.

Stay Safe !
Stay Healthy !

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.