I need some assistance with a task I’m working on. Despite multiple attempts, I am only able to extract a single value using regex(used Regex as “Customer Register Number:(.*)”, and I’m hoping someone can help me resolve this issue.
Here’s the scenario: My goal is to extract all Customer Register Numbers (CRNs) present in each outlook email. Note that each email contains multiple CRNs.I have to extract each CRN and then copy each one into a web application.
Please note the following:
CRNs may contain characters such as “-”, “?”, or “~”.
Sometimes, the CRN appears without having details like message ID, keyword, or arrival time.
For example, an email might look like this:
Your Regex of “Customer Register Number:(.*)”, would not work because you are not considering the space. And you are not using Positive Lookbehind on Customer Register Number
Hi @V_Roboto_V I am encountering an issue with the workflow not able to add as list . Despite trying various scenarios, I consistently receive a value of (0) in each Outlook email only. I have attached my workflow for your reference.
Could you please provide some suggestions to resolve? issue.docx (157.4 KB)
Accordingly, accessing the values individually will also change (compared to my previous solution). You CANNOT access it as CRN(0).Value, instead you should access it as CRN(0).ToString
This will solve the Error. But to check whether the Regex works or not, I Would still recommend checking the value of the Body variable or currentItem.Body.ToString in the Immediate’s Panel.
If this solves your query, Do mark it as a solution
Happy Automation
Thank you for the response. I checked the value of the Body variable in the immediate panel, and it is correct. There is no issue with this.
However, the problem is that I am only receiving the CRN(0) values three times from three Outlook emails, but not the subsequent CRNs. Attached the same for your reference. Could you please advise on how to resolve this?
and moreover i am not getting match collection(4)?
You are using Add Data Row only once with CRN(0), Shouldn’t it be enclosed in a For Loop so that you can iterate through the CRN list?
There Could be one of 2 possible issues or Both.
Regex Pattern is not dynamic enough: For which, I suggest you do the following: Show me the CRN list Values from Immediete’s Panel and also the Body. You have said that Body has no issues, but CRN has no values (extracts only 1), This means that there is a problem with the Regex pattern.
Just show the value of the body and CRN, So I that i can fix the Regex and provide a Dynamic one. I cannot give a solution blindly; I need to debug step by step from the root cause. If the Body has sensitive data, Mask it.
You have some issue in the logic.
I observed your Doc file again, and noticed that the extraction process is inside a For each Message list. This means you are extracting the CRN for each Body and then adding it to the DataTable, which is Fine. But the issue is with the Add Data Row, you are adding only CRN(0). Instead, you should surround the Add Data Row in a For Each Activity. Reference Screenshot: