Hello mzahid,
Thank you for your answer.Replacing mail.Headers with mail.Body returns null(in test with message box).That’s the reason i’m using mail.Headers.
I print in message box mail.Headers(“PlainText”), it is correct and doing what exactly i want but it stuck at if statement with the exception i mentioned above.
i’m holding an int variable to count if any of mail messages found in the above if statement.If mail found with my string i assign this in as :
noOfMails =noOfMails+1
And then outside the loop i’ve got another if that is checking if noOfMails is 0 message box no mails found,else if noOfMails >0 message box the noOfMails found in your mail box
Τhank you for your replies.But as i mentioned 2 times the problem is with mail.Headers and not with mail.Body.I tried both with your solution and robot finished (but it’s not finding the string inside the mail) using the mail.Body and with mail.Headers (finds the specific string) but it’s a problem with object reference in if condition.The problem is that the only way to achieve the requested string to be found inside the body is to use mail.Headers.If you try your solution with mail.Headers you will get an error.
mail.Body returns null due to almost all mails are using html format encoding and thats why mail.Headers(“PlainText”) help us solve this problem, but its a strange exception occurred while processing inside if.
I resolve it using a try catch block and add exception with log message activity.It throws 3 exceptions in log message and continues.It’s also find the correct email.
See the attach
Thanks for your help.
Tried your code in message box and you will see that returns null message box.It’s not reading html body messages as text.Probably your mail box not having html messages.
Already done that mate.
if you find the forum you will see that if you want to search for a specific string in mail body is better to use mail.Headers.