I´m trying to extract information of subject emails, the application who send emails it´s going to send me a lot of emails per second, where the subject email changes every moment, so I want to extract 3 specif data. First it´s going to be ODT, second it´s DUCA. The third data is in the body, it will be Status.
For now I´m trying to extract ODT and DUCA, but regex its´n working because when I run the project the messages box are empty.
When the robot reads the subject has to display a messages box indicating if in the email it has found the complete information, I mean ODT: XXXXX and DUCA: XXXXX. If any email it´s missing ODT or DUCA, it has to display a messages indicating that the email doesn´t have ODT or DUCA, and send and email with this messages to technical support. Then the robot has to read and extract the status, and this status it´s going to has many classification, so the robot has to qualify if the status meets the default status
The first image is from de messages box and the second image is from the email which I need to extract the information.
Please somebody help me with this project!
VISDOM.7z (11.2 KB)
Instead of using Regex, we can use contains right.
If subject.contains(“ODT”)----> message box should display ODT
ELSE subject.contains(“DUCA”)----> message box should display DUCA
ELSE-----> message box should display as email does not have ODT or DUCA
Thank you so much!
What activity can I use for that?
Hi! I tried this way, but when a run the project the for each activity search all emails with the subject ODT: GT-XX-XXXXX - DUCA: XXX-XXXXXXX, search some emails only with ODT: GT-XX-XXXXX and others with DUCA: XXX-XXXXXXX. But the issue is that the for-each activity search twice and displays twice the information. And I don’t want it to display repeated information to users.
Do you have any suggestion for me?
@mermonrroy Can you put in the file as .zip? I cant read 7zip files and we can’t download software on company machines
Yeah sure, I uploaded a file .xaml and .7z, you can use any of both. Thank you so much for helping me!
Main.xaml (30.9 KB)
VISDOM.7z (11.2 KB)
I downloaded the .xaml but am not sure which activity packs you’re using? I am getting a ‘missing or invalid activity’ for the first 2 activities in the Default portion of the Switch statement.
This are the activities and the second image is how looks my project. I will upload the project again.
Main.xaml (30.9 KB) project.json (901 Bytes)
@mermonrroy I am on 18.4.3 so I can’t use open your file. It needs 18.4.4 or above for those activity packs. I will do my best to provide some regex statements based on your comments here.
I am using the following as my input text:
FW: Cambio de status en ODT: GT-IM-18839 - DUCA:251-9538546
Regex to pull out the ODT:
Assumptions: ODT is followed by a colon and a space
: and you want all characters until the next whitespace
Regex to pull out the DUCA:
Assumptions: DUCA is followed by a colon
: and no space. You want all characters until the next whitespace.
To pull the status, if it will always contain the entire status on one line and you want to grab the entire line I would recommend using String.Split by Environment.Newline and then using a for each statement to see if the line contains the word “Status:”. If it does, then the entire line of text is your status.
If you really want to pull the status using regex that is certainly possible though. Simply do the following
Status: i5 Solicitando ATC
Assumptions: You want to pull the entire line of text starting with the string
Status:. There is only one line with the word status, or you only want to pull the first one.
I would structure the workflow like this:
- Get all messages.
- For each message
2a. Read subject line and save as string variable (i’ll call subject)
2b. (in an if activity) Regex.IsMatch(subject,"\bODT: \S+\b"
2c (on true side of 2b’s if activity) Assign ODC (a string variable) = Regex.Match(subject, “\bODT: \S+\b”)
2d. (on false side of 2b’s if activity) Assign ODC = String.Empty
2e. (in an if activity) Regex.IsMatch(subject,“DUCA:\S+\b”)
2f. (on true side of 2e’s if activity) Assign DUCA (a string variable) = Regex.Match(subject, “DUCA:\S+\b”)
2g. (on false side of 2e’s if activity) Assign DUCA = String.Empty
2f. (in an if activity) String.IsNullOrEmpty(ODC) AndAlso String.IsNullOrEmpty(DUCA)
2g (on true side of 2f’s if activity) send email to support that both ODC and DUCA is empty
2h (on false side of 2f’s if activity) Assign Status (a string variable) = Regex.Match(YourEmailBodyAsStringVariable,“Status:.+”)
2i (still on false side of 2f’s if activity) do any other activities related to this email within here
I really appreciate your support, thank you so much for your help and your time, in this time I will try your solution. Can I sent you a message if I have some doubts?
@Dave I did what you wrote for me and it´s work but when the project try to extract DUCA the message box is empty, and when you mention about the " YourEmailBodyAsStringVariable " variable, I did not understand it.
This how it look the project. Thank you so much for your help!.
I just figured you had the body of the email saved as a string variable already. I meant to use that (mail.body.tostring if you don’t have a variable for it already).
As for why the messagebox is empty I am unsure. According to your workflow the message box will only pop up if there is a regex match so it shouldn’t be empty. Can you copy+paste the output that you are getting from mail.subject.tostring? Use a write text activity or a write line or a log message activity to do it. Then use the
preformatted text here to make sure nothing gets messed up when trying to post it here
@Dave It´s work, It was my mistake, now the project shows me DUCA in the message box. Thank you so much for your support and your help. You´re cool!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.