Read Body of Outlook mails

Hi all,
I am new to Uipath. I want to read the body of all unread messages in outlook mail one after another. And wants to check the condition for only two mails.

For example : if first mail contains body as “success friend” and the second mail
body contains as “success unfriend”.

Now what i want to do is first i want to read first mail and check whether the body contains “success friend” and next i want to read second mail and check the body contains “success unfriend”. After that i want to display message as “Both mails are success”.If i did not receive body like that in both mails i want to display as “Both are failed”. If any of the body does not contains the message as specified then display the message which does not works properly whether it may be “unfriend failure” or “friend failure”.

Thanks in advance

Hi Greetings!

Please refer this xaml.

outlook_test.xaml (7.4 KB)


@Bindhu you can use if condition like item.body.contains(“success friend”) or item.body.contains(“success unfriend”) if any mail body contains these values it goes to then section there you can maintain a message box as both mails are success if it don’t contain those it goes to else section there maintain message box as both are failed.try this it might work for you.

Hi @venkatmalla6

If it fails then it goes to else case right. but i want to display a message in which case it fails whether in “success friend” or “unsuccess friend”. If both fails i want display “Both Fails”.


@Bindhu Use condition like this

if(item.Body.Contains(“success friend”))
// statement
else if(item.Body.Contains(“success unfriend”))
// statement
//fail statement

@Bindhu if that is the case use if condition and give only condition like item.body.contains(“success friend”) if it finds it goes to then section there you can give finds the success friend,say if that body don’t contains success friend it goes to else section there use one more if condition and give **item.body.contains(“unsuccess friend”)**if it finds that it goes to then section there give message box as finds unsuccess friend if it don’t finds success and unsucess friend it goes to else condition there give message box both fails.
so now as you can see initially it looks for success friend in first condition if it finds that it will give you message box as finds the success friend
-if it don’t find the success friend it goes else condition there as we mention one more if condition for unsuccess friend if that contains unsuccess friend it goes to then and give you message as finds unsuccess friend.
-if it don’t contains two it goes to else part of second if condition there you can give both fails.
i think this will satisfy your above requirement.plz let know if any thing needs.

@venkatmalla6 Thanks for explanation.

Both Mails are different i want to keep message box out side of for each loop.If i kept there itself it printing two times.I want to check two mails one after the other and finally based on the result i want to display the message as success or failure in any of the case or failure in both.

@Bindhu i have a doubt are you reading numerous mails or just reading two mails.plz correct me

@venkatmalla6 Two mails.

@Bindhu if that is the case use if condition as item.body.contains(“success friend”) or item.body.contains(“success unfriend”) if it satisfies the above condition it goes for then section create a integer variable and in then section use assign activity and give like this say the int variable name is counter.then in assign activity counter=counter+1give like outside the for each loop use a if condition like counter=2 if it satisfies it gives the output as both success and unsuccess successful.
-now back to the for each loop,here create one more integer variable say encounter with default value else condition give like this encounter=encounter+1
-below it use if condition as encounter =2 it goes to then section there mention both are failed,in else condition use write line as item.body.

@Bindhu mention this full condition like how i gave item.body.contains(“success friend”) or item.body.contains(“success unfriend”)

@venkatmalla6 Thank you.Can you please share xaml file.

@Bindhu Main.xaml (8.5 KB) have a look let me know if any thing goes wrong.

@venkatmalla6 It working well.But it does not displaying the message in which case it fails whether in “Success friend” or “success unfriend”.it gives output like this.

@Bindhu if possible can you run it in debug mode and post screenshots of that.

@venkatmalla6 Here the screenshot attached below.

@Bindhu Main.xaml (9.4 KB) i just made small modification have a look.

@venkatmalla6 Still getting output as 1.It does not displaying message box.

@Bindhu for me it’s working and even showing the message box also.

@venkatmalla6 No it does not showing any message box.