If condition to read attachment

Hi
iam using if condition to read mail attachment so if the attachment in any other format the process go to then -except “.xlsx”

if the attachment is .xlsx the process go to ELSE

i use the following condition - “CurrentMail.Attachments.Where(Function(x) x.Name.Contains(”*.pdf")).Count=1"

in above condition i need to include all formats except Excel to go ELSE

any posibile

Thanks in advance

Hi @jai_kumar2 ,

You can use like this

CurrentMail.Attachments.Where(Function(x) x.Name.Contains(”*.xlsx")).Count=1

If xlsx , it will go to then .
If not xlsx, it will go to else, you can add your further validation under else.

Thanks

Hi @jai_kumar2

Can you please give a try on the below expression ?

CurrentMail.Attachments.Where (Function(x) Not (x.Name.Contains("*.xlsx"))).Count=1

Regards
Gokul

1 Like

Your condition is built the other way around:

Current LINQ → You’re checking if there is any attachment with .pdf as extension
LINQ that you want → Check if there is any attachment NOT having .xlsx as extension

for that I’d suggest trying the expression posted here by @Gokul001

1 Like

Hi thanks for teh reply
in outlook received mail have .xlsx format attachment but condition goes to else

what will be the possible reason for this

Hey

Try with

CurrentMail.Attachments.Where (Function(x) (x.Name.Contains(“*.xlsx”))).Count=1

In the then part make the process when the document is xlsx, in the else part do the process for rest type of documents

Regards

There is any possibility that, excel attachment format may not recoginized by bot

Have you tried with this expression? @jai_kumar2

Kindly note:

  • LINQ, String method contains does not support the wildcard star
  • To robusten it up it can help to do a case insensitive check
  • maybe not an issue due minimal items count, but a where…count=1 construct is recommended to transform it to a where(…).Any() or Any( with LAMBDA) construct. We give therefore the option to stop, when a first item is found

In general we recommend to use the immediate panel for the direct prototyping:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

have a start with (checking all attachments if any non xlsx is present):

CurrentMail.Attachments.Where(Function(x) Not x.Name.ToUpper.EndsWith(".XLSX")).Any()
1 Like

Thank you all

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.