I have a requirement of reading alert emails using Automation Studio which status of the Alert is in the body of the Email. I am able to read and save the Email. Can you suggest a better way to read the text and get the field in the body of an Email.
Only way is to use Read Email activity and store the mail content (body and subject ) in a user specified folder. Post that text has to be parsed from txt files saved
Open file activity will only open the file and not read the contents of the file.
Alternatively you can use File handling commands to read text from txt file. I am giving you an exapmle how you can do the same in Studio to read a text file having single line
Create three arguments:
fileP - String (Type) - Argument where my path exist
FileReader - System.IO.StreamReader (Type) - TO read my file
Str- String(Type) - To store thre read content
Step1:
Use a Assign actiivty and assign
FileReader = System.IO.File.OpenText(fileP)
Step2:
Use a Assign actiivty and assign
Str = FileReader.ReadLine()
Post that you can use this Str variable as per your use case. In my exapmle i have simple written it in out put console. You can also write more complex logic to iterate through each line of text file using loop
I have implemented my requirement. But How to Dispose opened StreamReader(It is throwing error sometimes).
I have tried FileReader.Close() in Assign. But as its return type is null it is showing me compilation Error.(Tried Adding a string after FileReader.Close(), again shows compilation Error.)
For methods which are not returning anything it is not possible to use Assign activity as it expects some value assigned to some argument.
In case Close environment is not fulfilling your purpose and FileReader objects are getting piled up then best option is to use Microbot or Code Editor and dispose the object programatically.
You can refer AssistEdge-CE-CustomizationGuide.pdf for more details