Hi I new here, so I need to iterate through mail and check their subject if the subject is "Invoice I need to proceed further or else I need to throw an error after loop is completed I already created workflow but its not working when email subject is dif

Hi @Simran2,
I think in if condition you provide email.subject.toString.toLower.contains(“invoice”) will be more precise to get emails which contain invoice in their subjects.

Thanks & Regards,
Shubham Dutta

Hi @Simran2 ,

Try Checking the options provided in the post below :

still not working

@Simran2 Hi simran, I solved already, where you are facing issue

in 2nd if else condition
its not throwing an error for different subject

@Simran2 please show your full

@Simran2 ,

Can you put the Screenshot here of your workflow.

please follow these steps.
1-get unread mail messages list from mail.
2-loop over mail message list.
3-put condition inside loop.
4- Condition Item.Subject.ToString.Contains(“Invoice”)
5- if the condition is true put all the process in your then block.
6- if mail not contains “Invoice” then put assign activity in else block and in assign activity put bool variable.
7- use bool variable outside if where you want to throw exception

Hi @Simran2,

I think in GetOutlookMailMessage, put condition “@SQL=(urn:schemas:httpmail:subject LIKE ‘%Invoice%’)”.
This will fetch all unread mails where subject line contains Invoice keyword and then in if condition you can check if mailMessage count>0, proceed with steps else throw exception.
This way we can avoid loop as well.

Thanks & Regards,
Disha Jain

@Simran2 please share .xml file, I want to design

@Simran2 ,

As per your Workflow out of 10 Emails even if 1 Email contains required Subject it will not go to else part and throw the exception.

Out of N Emails even if 1 contains invalid and if u need to throw exception in this case you need to reverse the condition in 1st If - Else block.

Assign Boolean = True in else block (which means Invalid Email found)

In 2nd If - Else block if your Boolean is true throw exception.
This way it will throw exception even if 1 Invalid found.

But not sure what is your need here, this suggestion is based on your workflow.

Hope it helps!


still not working

@Simran2 please share your file

@Simran2 Its working solution and I don’t know why its not working in your end

its saying new user cannot share file