Mail attachment extension switch

Dear UiPath team,

I’m building a switch that determines if there is an .xlsm and also a .pdf or only an .xlsm extension in the mailattachment. I came up with the switch expression:

If(extension.Equals(“.xlsm”) AndAlso extension.Equals(“.pdf”), “True”,If(extension.Equals(“.xlsm”), “False”))

I’m getting an error: BC36913: Cannot infer a common type because more than one type is possible.

What am i doing wrong?

we would recommend to avoid the nested check.

Can you reformulate / realign the requirement?

Maybe also this helps

Collect all extensions:

arrFoundExt =

YourMail.Attachments.Select(Function (x) Path.GetExtension(x.Name).toUpper).Distinct().toArray

then check with
new String(){".PDF",".XLSM"}.All(Function (x) arrFoundExt.Contains(x))


First of all use if activity instead of switch as you have only two conditions

Apart from that the same extension can never be a xlsm and pdf …so you have to go with checking all at once instead of using loop for attachments

What @ppr can be used as the formula but again in if condition


@ppr Hey Peter!

Of course! My colleagues will be sending me an email with two possible attachments. One attachment will be a calculation form in .xlsm format, and the other attachment, which is optional, will be a consent letter from a resident in .pdf format.

The robot’s task is to examine the email and attachments in the following way:

  1. The robot will retrieve the email.
  2. It will gather information about the types of attachments.
  3. The robot will then verify if both a .xlsm file and a .pdf file are attached, or if there’s only a single .xlsm attachment.
  4. Based on the attachments, the robot will take appropriate actions.

@Anil_G Hey Anil, thank you, good tip!
You’re right i need to check all at once

1 Like

can be checked with above given statement

Based on your description I would design the flow as follows:

check if *.PDF attachment exists
YES → go the PDF & XLSM route
NO → go the XLSM-only route


Thanks everyone!

1 Like

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