Ricchch
(Ricardo)
January 16, 2024, 6:32pm
1
Hello Friends,
i would really appreciated if you could help me with this problem.
I need to verify if an outlook email has an attachment and then check if the attachment name is composed by 4 number
Ex 1234.xlsx or 8945.xlsx
i using this regex but i doesn’t work
mail.Attachments.Any(Function(x)x.Name.ToLower.Contains(“123456789”))
could you please help me with that?
thanks in advance…
Richch
pikorpa
(Piotr Kołakowski)
January 16, 2024, 6:46pm
2
Hey @Ricchch
Try to use for each to loop through the email attachments and then use if activity:
System.Text.RegularExpressions.Regex.IsMatch(CurrentItem.Name, "^\d{4}\.xlsx$")
1 Like
vrdabberu
(Varunraj Dabberu)
January 17, 2024, 2:11am
3
Hi @Ricchch
Can you try this in If Condition when you use For Each loop to iterate through mailMessages variable:
mail.Attachments.Any(Function(x) System.Text.RegularExpressions.Regex.IsMatch(x.Name, "\b\d{4}\.xlsx\b"))
Regards
1 Like
lrtetala
(Lakshman Reddy)
January 17, 2024, 2:55am
4
Hi @Ricchch
Can you try the below
isAttachmentValid = mail.Attachments.Any(Function(x) System.Text.RegularExpressions.Regex.IsMatch(x.Name, "\d{4}\.xlsx", RegexOptions.IgnoreCase))
Cheers!!
1 Like
Ricchch
(Ricardo)
January 19, 2024, 12:20pm
5
Hello @pikorpa @vrdabberu @lrtetala
Thanks for helping.
I couldn’t yet test your advises (some last minute changing priorities)
i will do it next week and i will get back to you.
In the meantime have a good weekend and thanks again.
Ricchch
2 Likes
Ricchch
(Ricardo)
January 22, 2024, 8:02pm
6
pikorpa:
^\d{4}.xlsx$
Hello @pikorpa ,
thanks for messaging
i tried to capture this excel file
Using this phrase in If condition
But didn’t work…
do i have to correct something? thanks for helping
lrtetala
(Lakshman Reddy)
January 23, 2024, 2:45am
7
@Ricchch
Can you try the below
currentItem.Attachments.Any(Function(attachment) System.Text.RegularExpressions.Regex.IsMatch(attachment.Name, "\b\d{4}\.(xlsx|xls|csv)\b", RegexOptions.IgnoreCase))
Cheers!!
1 Like
Ricchch
(Ricardo)
January 23, 2024, 7:18pm
8
Hello friends @vrdabberu , @lrtetala @pikorpa
Thanks for helping to all of you.
Statement in the if conditions
I followed your recommendation with the following
(mail.Attachments.Any(Function(x) x.Name.ToLower.Contains(“.xlsx” )) Or mail.Attachments.Any(Function(x) x.Name.ToLower.Contains(“.xls” )) Or mail.Attachments.Any(Function(x) x.Name.ToLower.Contains(“.csv” )))
AND
(mail.Attachments.Any(Function(x) System.Text.RegularExpressions.Regex.IsMatch(x.Name, “\b\d{4}\b”)))
with this phrase i am able to filter attachments having extension .xlsx, .xls and .csv
then with the next expression i was able to check if the name of the attachment has 4 characteres .
I would really appreciated if you could help me with this extra requirement:
i need this las phrase to be able to filter the name of the attachment but only one having numbers in the attachement name.
Rightnow, the “\b\d{4}\b” seems to filter just those names that has 4 characteres . in other words. if the attachement name is abcd.xls it will got into the IF then . Same for a attachement name 1234.xls
however , i need the phrase condition to send abcd.xls to the Else part of the conditionnal…
Thanks again for any advice or help,
Ricchch
vrdabberu
(Varunraj Dabberu)
January 23, 2024, 10:17pm
9
Hi @Ricchch
Can you try the below syntax in If:
mail.Attachments.Any(Function(x) System.Text.RegularExpressions.Regex.IsMatch(x.Name, "^\d+$"))
Regards
Ricchch
(Ricardo)
January 24, 2024, 1:57pm
10
thanks @vrdabberu
but didn’t work
Ricchch
vrdabberu
(Varunraj Dabberu)
January 24, 2024, 2:03pm
11
@Ricchch
Can you send the screenshots of the workflow what is your exact condition you want t check.
Regards
Ricchch
(Ricardo)
January 24, 2024, 2:15pm
12
Hello @vrdabberu
thanks for helping.
in the image below you will find an email with 5 excel attachments.
there are three attachments that complies with requirements ( their names are composed by 4 numbers ) .
Besides that, there are two attachments not complying with requirements( their names have less than 4 numbers or their names are composed by letters)
Therefore , i need the program to be able to filter those having 4 numbers in their names and eliminate those having letters or les than 4 numbers)
My actual phrase in If conditions is:
Thanks
vrdabberu
(Varunraj Dabberu)
January 24, 2024, 2:17pm
13
@Ricchch
Are you sure that the excel that you get will contain 4 numbers?
Regards
Ricchch
(Ricardo)
January 24, 2024, 2:23pm
14
@vrdabberu
yes… its a requirement.
Thanks
vrdabberu
(Varunraj Dabberu)
January 24, 2024, 2:30pm
15
Hi @Ricchch
Can you try the below syntax:
Try the below syntax:
(mail.Attachments.Any(Function(x) x.Name.ToLower.Contains(".xlsx")) OrElse
mail.Attachments.Any(Function(x) x.Name.ToLower.Contains(".xls")) OrElse
mail.Attachments.Any(Function(x) x.Name.ToLower.Contains(".csv"))) AndAlso
mail.Attachments.Any(Function(x) System.Text.RegularExpressions.Regex.IsMatch(x.Name, "^\d{4}\.(xlsx|csv|xls)$"))
Regards
Ricchch
(Ricardo)
January 24, 2024, 2:38pm
16
@vrdabberu
i tried but it processed all the files (included those ones with three numbers and letters that are supossed not being processed)
Thanks
vrdabberu
(Varunraj Dabberu)
January 24, 2024, 2:43pm
17
Hi @Ricchch
Try the below syntax:
mail.Attachments.Any(Function(x) System.Text.RegularExpressions.Regex.IsMatch(x.Name, "^\d{4}\.(xlsx|csv|xls)$"))
Regards
Ricchch
(Ricardo)
January 24, 2024, 2:46pm
18
its exactly the same i tried.
Thanks
1 Like
vrdabberu
(Varunraj Dabberu)
January 24, 2024, 2:47pm
19
@Ricchch
I think your query will be resolved now. If yes, please mark my post as solution to close the loop otherwise if you have questions, I’m happy to help
Regards
Ricchch
(Ricardo)
January 24, 2024, 2:51pm
20
@vrdabberu
no , my query was not resolved it has the same problem.
But thanks anyway for trying to help.