Hi, I would like the bot to read an excel file by matching email address. If the email and the excel file has the same/matching email address, I need the bot to take the next column information to be inserted into the next step which is a forwarding email.
Hi @mnurhaikal
Can you share some informative dummy screenshots on your use case?
Try this activity: Activities - Lookup Data Table
Hi @mnurhaikal
Try this way below:
- Use the Filter Data Table activity to filter rows in dataTable where the email matches your target email.
• Input DataTable: dataTable
• Output DataTable: filteredDataTable
• In the Filter Rows section:
• Column: [Email] (or the exact column name where the email is stored)
• Condition: =
• Value: targetEmail (the email address you’re searching for)
- After the filter, filteredDataTable will contain only the rows where the email matches targetEmail.
Use this command in the assign activity to take the e-mail
infoToForward = If(filteredDataTable.Rows.Count > 0, filteredDataTable.Rows(0)(“Information”).ToString, “No match found”)
Hi everyone i managed to solved it. Thanks! I actually keyed in "Excel.Sheet(“Sheet1”).
Hey @mnurhaikal,
Welcome to the community!
To achieve your requirement of reading an Excel file, matching an email address, and then retrieving information from the next column, here’s a step-by-step solution using UiPath:
Solution:
Step 1: Read the Excel File
- Use the “Excel Application Scope” activity.
- Inside it, use the “Read Range” activity to read the data into a DataTable (let’s call it
dtEmails
).
Step 2: Use a For Each Row
to Loop Through the DataTable
- Use a “For Each Row” activity to iterate over
dtEmails
.
Step 3: Match the Email Address
- Inside the loop, use an “If” activity to check if the email matches:
row("Email").ToString.Equals(targetEmail, StringComparison.OrdinalIgnoreCase)
- Replace
"Email"
with your actual column name containing email addresses. targetEmail
is the email address you’re searching for.
- Replace
Step 4: Retrieve the Next Column Value
- If the email matches, get the value from the next column:
nextColumnValue = row("NextColumnName").ToString
- Replace
"NextColumnName"
with the actual name of the column you want to retrieve.
- Replace
Step 5: Use the Retrieved Value
- You can now use
nextColumnValue
for your forwarding email step.
Example in UiPath:
For Each row in dtEmails
If row("Email").ToString.Equals(targetEmail, StringComparison.OrdinalIgnoreCase)
nextColumnValue = row("NextColumnName").ToString
Exit For
End If
End For
Alternative: Use LINQ (If You’re Familiar with It)
You can also use LINQ for a one-liner solution:
nextColumnValue = (From r In dtEmails.AsEnumerable()
Where r("Email").ToString.Equals(targetEmail, StringComparison.OrdinalIgnoreCase)
Select r("NextColumnName").ToString).FirstOrDefault()
I hope this helps! Let me know if you need further clarification.
Best,
Chaitanya