How can we utilize the "Switch" activity to dynamically adjust our workflow based on emails received from specific addresses such as those with @hdfc, @Kotak, or @Citi?

How can we utilize the “Switch” activity to dynamically adjust our workflow based on Outlook emails received from specific addresses such as those with @hdfc, @Kotak, or @Citi?

Hi @Ajinya_jorwekar

For Switch Case

For Each email In OutlookEmails
Switch email.Sender.Address
Case “@hdfc.com
// Perform actions for HDFC emails
Case “@kotak.com
// Perform actions for Kotak emails
Case “@citi.com
// Perform actions for Citi emails

Hope this helps

@Ajinya_jorwekar

  • Step 1: Retrieve emails using “Get Outlook Mail Messages.”
  • Step 2: Use a “For Each” activity to iterate through each email.
  • Step 3: Inside the loop, use an “Assign” activity to get the sender’s email address.
  • Step 4: Add a “Switch” activity after the loop with senderEmailAddress as the expression.
  • Step 5: Add cases for specific email address patterns and include relevant activities.
  • Step 6: Optionally, add a “Default” case for other emails.

For Each mail In mailMessages
senderEmailAddress = mail.SenderEmailAddress

Switch senderEmailAddress
    Case "@hdfc.com"
        ' Add activities for HDFC emails
    Case "@kotak.com"
        ' Add activities for Kotak emails
    Case "@citi.com"
        ' Add activities for Citi emails
    Case Else
        ' Default case for other emails
        ' You can either leave it empty or add activities for other scenarios
End Switch

End For Each

Hi @Ajinya_jorwekar

=> Use Get Outlook Mail Messages to iterate through unread mails.
=> Use For Each loop to iterate through list of Mail Messages.
=> Use the below syntaxes in Assign activity:

SenderAddress= currentItem.Sender.Address
Address= System.Text.RegularExpressions.Regex.Match(SenderAddress,"\@[A-Za-z]+").Value

=> Use Switch activity and give the conditions like @hdfc, @Kotak, or @Citi

Refer the below image for better understanding:

Hope it helps!!
Regards