I’m trying to extract three variables from an email body. I’m able to log into the mailbox successfully, and load the message, but I’m unsure how to parse the text into variables that will then be used as variables in a web app workflow.
Fine
—once after getting the list of mails from mail activity named as list_mails
—now use a FOR EACH activity and pass that list variable as input and change the type argument as System.Net.Mail.MailMessage
—inside the loop use a ASSIGN activity like this list_string = item.Body.ToString.Split(Environment.NewLine.ToArray()).ToList()
Where list_string is a variable of type System.Collections.Generix.List(of string) with default value as New List(of string) defined in the variable panel
—now inside this for each loop use another FOR EACH activity and pass the above variable list_string as input and change the type argument as string the property panel and change the variable name from item to line
—inside this inner for each loop use a assign activity like this str_TaskName = IF(line.ToString.Contains(“TaskName”), Split(line.ToString,”;”)(1).ToString.Trim, String.Empty)
Similarly use two more for other two values to be obtained str_ProjectNumber = IF(line.ToString.Contains(“ProjectNumber”), Split(line.ToString,”;”)(1).ToString.Trim, String.Empty)
@Palaniyappan, thanks so much for the help. I believe I’m getting close with this information, but have a couple of questions. On your first list, I believe I’m having an issue with not correctly understanding the point of, “once after getting the list of mails from mail activity named as list_mails.” I used this variable in the Output → Result of the Get Mail function, but this generates the following error. I’m not sure if that was the intended place for this variable name, and if so, what type it should be configured as to remove the error:
@Palaniyappan, I think I’m almost there. Switching to IMAP allowed me to save the body to a variable. The email is being read, as it’s changed from unread to read. No errors are reported, however the data is not being assigned to the string variables.
In the attached screen shot, I’m breaking after the strings should have been assigned to the three variables. The email is getting read, and marked as read. Also in the screen shot to the right is the text of the email.
Also, while debugging and looking at the body of the email that’s returned, it’s being returned in HTML format, which might be causing a parsing issue?