Azure, Logic Apps, Action 'Send an email(V2)' of Office 365, compare body input email address with actual to-recipient address

SashaM 20 Reputation points
2024-11-12T11:24:26.3433333+00:00

Hi everyone,

I'm reaching out for advice on a scenario I'm working with in Azure Logic Apps. Here’s the setup:

I have a "When HTTP request is received" trigger, which receives specific parameters in the request body. One of these parameters is the manager's email address. I need to use this email address as the "To" recipient in an "Send an email (V2)" action with Office 365.

However, before sending the email, I need to verify that the manager’s email from the request body matches the actual recipient email in the To field (in case the email was redirected or forwarded to another recipient). Does anyone have an approach or workaround to handle this validation step?

Any ideas or suggestions would be greatly appreciated!

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,252 questions
0 comments No comments
{count} votes

Accepted answer
  1. Khadeer Ali 1,220 Reputation points Microsoft Vendor
    2024-11-13T01:37:49.8666667+00:00

    Hi @SashaM,

    Welcome to the Microsoft Q&A Platform!

    Thank you for reaching out regarding your question on Azure Logic Apps and the "Send an email (V2)" action in Office 365. Below is a solution on how to compare the email address provided in the HTTP request body with the actual "To" recipient address before sending the email.

    1. Trigger: When an HTTP request is received
      Configure this trigger to accept parameters in the request body, including managerEmail
         {
           "properties": {
             "managerEmail": {
               "type": "string"
             }
           }
         }
      
    2. Initialize Variable: Add an Initialize Variable action to store the managerEmail value from the HTTP request body.
          **Name**: `managerEmail`
         
         
          **Type**: `String`
         
         
          **Value**: `@triggerBody()?['managerEmail']`
         ```1. **Condition to Verify Recipient**:  
      

    Add a Condition action to verify if managerEmail from the request body matches the intended manager’s email.

    equals(variables('managerEmail'), 'manager@example.com')
    If True Path (Emails Match):

    In the If True branch, add the Send an Email (V2) action to send the email to the verified recipient.

    From: Sender email

    To: Manager email (verified)

    Subject: Custom subject as needed

    Body: Custom body as needed

    If False Path (Emails Do Not Match):
    In the If False branch, handle the case where the emails do not match. This may involve

    Overall, the Designer looks like the image below:
    User's image

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.