How to loop through csv list to find match in email body

Sorry if this has been covered as I am new to this forum, but the issue is that I am I am trying to loop through a csv file containing 50 names, of which only 1 at a time will be included in the message body of an incoming email. Once the proper name is matched it will trigger the rest of the automation. Any ideas?

Tagged:

Comments

  • Hi Adam

    I think you'd need to have a loop inside a loop to deal with this situation.

    So for each new mail in a particular inbox, you'd want to open your CSV file and check if the message body of the mails in the inbox contained the values you read from your CSV.

    If it finds the value you then go call a child task which goes off and does what you need it to do.

    So in basic code you'd want the following kinda idea:

    1 Comment: *** Damian Griffiths - Extra Techology - Email test bot ***
    2 Start Loop "Each unread message on server: mail.office365.com, User Name: student1@extratechnology.com, SSL, ServerType: IMAP, Message Format: Plain Text"
    3 Comment: Please enter your commands to loop. Use Email Automation variables for each email on Server.(e.g. $Email From$, $Email To$, etc.)
    4 Message Box: "Email from : $Email From$About: $Email Subject$Email date: $Email Received Date$ $Email Received Time$"
    5 Read From CSV file: "C:\Users\Administrator\Desktop\AA Training Materials\MetaBot\Names.csv" Delimiter: "Comma" Header: "Yes" Trim Leading Space: "Yes" Trim Trailing Space: "Yes" Session: 'Default'
    6 Start Loop "Each row in a CSV/Text file of Session: Default"
    7 Variable Operation: $Filedata Column(1)$ To $v_NameSearch$
    8 Message Box: "Search name: $v_NameSearch$"
    9 Comment: Use $Filedata Column$ variable for each record in File.
    10 If $Email Message$ Includes $v_NameSearch$ Then
    11 Comment: Please enter the conditional commands here.
    12 Run Task "C:\Users\Administrator\Documents\Automation Anywhere Files\Automation Anywhere\My Tasks\Sample Tasks\Loops.atmx" @Repeat: Do Not Repeat @Speed: Normal Speed @Pass Variable as argument: $v_NameSearch$
    13 Else
    14 Message Box: "$v_NameSearch$ was not found in this email "
    15 End If
    16 End Loop
    17 End Loop

    So start a loop to search the mail box ( for all unread messages )
    Then inside that loop open your CSV and search each of the messages '$Email Message$' variables where the name is included in that field.
    If it finds the value, then you spawn your sub task ( in my case I've just started the loops.atmx task ) and I've passed the name I found to the child task to go off and do something.

    That make sense?

    Kind regards

    Damian

Sign In or Register to comment.