Using if else action


#1

Hey at all,

i have automated a flowchart where i start storing PDFs from Outlook in one folder, open this PDF, using ocr to get a specific number, starting a SAP Transaction with this number and finally delete the PDF in the folder.
As you can see in the Picture i connected the last flowchart with the first one, so that i have a loop and the process runs as long as i have unread emails with PDFs. So now i want to use a il else Action in the second sequence, so that the process stops when the Robot can’t find any PDF in the folder. Do you have any idea what to type in the condition text field to tun this Action. Thanks a lot.


#2

Hi @tobschroer,

First of all, you shouldn’t use the If Activity here if your purpose is to exit the loop after checking all emails with the PDF attachments. Instead you should use the Flow Decision Activity just after your fourth sequence (or after your first sequence if you need to check your mail again). If you just add an If Activity and a condition that fits, you will have an infinite loop.

This is what I would do:

  1. When checking the emails, you should just check all unread emails at once using a Get Mail Message Activity. (you can keep multiple MailMessage objects in a List<System.Net.Mail.MailMessage>.
  2. Loop through the MailMessage List (You should also do this with a Flow Decision Activity and an index that increments after each loop)
  3. Exit the loop after the last index

#3

Thanks @pathLessTaken,
i have already used get mail message activity with the list <System.Net.Mail.MailMessage>. I changed the properties so that the Robot only searches the unread mail and only the first one. After that the mail is marked as read so it is getting the next one.
Now i’m using the flow decision after this first sequence so that the Robot stops if there is no more unread mail. But i don’t know what to type in the condiotion field. Thanks a lot.


#4

Hi @tobschroer, you can put your condition as messages.Count > 0 .

Cheers.


#5

Perfect @quihan. Thanks a lot


#6

No worries @tobschroer. Have a good day.