Help sending outlook email with attachment: BC36754 Error

I am taking a RPA class on Udemy and one of the exercises is sending emails with attachments. I keep getting errors about Strings not being converted to IEnumerable.

I think it has something to do with the variable type. I reviewed a few threads discussing this same topic. I tried all of their suggestions but none of them worked.

Thanks

Hi @jcoleman

Please use the syntax as mentioned in below post.

Hi @jcoleman,

This error usually occurs because the Attachments property expects an IEnumerable (collection), but a single value is being passed.

Try using:

{ LocalResource.FromPath(attachmentPath) }

Alternatively, you can use the Collection Builder:

  • Click on + icon in Attachments
  • Select Build Collection
  • Add your file(s) there

Thanks!

Good Evening,

Thank you for the replies, but unfortunately, it still does not work. The full file pathway is stored in CurrentFile.FullName, but when I use the suggested syntax, I still get an error.

Hi,

Can you try to set the following expression in Attachment property of SendEmail activity directly?

attachments.Select(Function(x) LocalResource.FromPath(x))

Regards,

Yoichi,

That worked!!! Thank you.

However, I am not sure why, but I will add the details in case anyone else has the same problem.

For the Assign Box, I used the following:


Set Value = the actual pathway to the folder holding the attachments.

Will add the rest in another reply…one image per post.

Here is part two:


Per your guidance, I used attachments.Select(Function(x) LocalResource.FromPath(CurrentFile.FullName). The original syntax you provided was
attachments.Select(Function(x) LocalResource.FromPath(x)…I added the actual pathway in place of the second X in this expression.

Lastly, let’s talk about the variable type for the attachments, because it was not obvious. If you hover over the attachments field at the bottom of the Send Email box, it will tell you that the Type is IEnumerableIResource; however, this does not work. You must use IEnumerableString.

Thank you, Yoichi!!!

Hi @jcoleman,

Can you try this for multiple files:

attachments = New DirectoryInfo(“C:\YourFolderPath”).
GetFiles().
Select(Function(f) f.FullName).
ToArray()

Thanks

I will try this today.

Thanks