Send E-Mail attachment Itegration Service

Hello,

I am using the send E-Mail activity from the integration service package

I get the file with the wait for download acitivty. Which gives me the path in a fileinfo format. However the Send E-Mail acitivity expects an IEnumerable(ofIrecource).

Any Ideas how I can convert it?

@VLC,

I assume you have only one file to be attached. For this, follow these steps:

Pass this expression

LocalResource.FromPath(downloadedFile.FullName)

This will be same for O365 Send Email activity as well

Hi,
Open the Expression Editor, click the folder icon, and select a file. You can also provide the path in a dynamic way.

Hi @ashokkarale, I actually have to attach multiple files, will it work as well? Also I do not know the file name, it has to be the latest file which was downloaded

@VLC
I tried the scenario you mentioned and was able to figure it out.
Please check the solution in the attached screenshot to attach multiple files from a folder in a dynamic way.
Kindly mark it as a solution if it meets your request.

Directory.GetFiles(“C:\Users\Manas Lenka\Downloads”, “*.pdf”).Select(Function(f) CType(LocalResource.FromPath(f), IResource)).ToArray()


@VLC,

To get latest file from use this expression in assign activity

Directory.GetFiles("your\folder\path").OrderByDescending(Function(f) File.GetCreationTime(f)).First()

To attach multiple files, you will have to get their file paths in a list of string and then pass it like this to the send email activity

lstAttachmentFiles.Select(function(x) LocalResource.FromPath(x))

Refer this solution.

@VLC Please mark the response that clarified your Query as solution to close this conversation.
This will help us to stay engaged with more community questions.

Happy Automation :slightly_smiling_face:

Hi Ashok,

yes I haved used that way to run the process on my local PC for testing. However I am not sure that it will work om the virtual machine when I put it into the orechstrator.

Furthermore since I added the send E-Mail activity I get the following notification:

UiPath has some issue with the directory :
directory is ambiguous, imported from namespaces or types “System IO, Microsoft Graph”

Will do but unfortunatley it does not work yet.

Best would be If I can continue using the wait for download activity and use the variable to reference it in the send Email activity

Please check the attached sample workflow, it may be helpful for you.
SendEmail.xaml (9.7 KB)

For this do this change in your code like this

System.IO.Directory.GetFiles("your\folder\path").OrderByDescending(Function(f) File.GetCreationTime(f)).First()

This has worked to solve the issue.

However for the Send E-Mail activity I dont have a solution yet.

Manas has put the expression directly into the send E-Mail activity. Cant I use the same expression two times, once with “first” at the end and once with “second”?

@VLC,

This expression will give you all the files there in the specific folder

ienumFiles = Directory.GetFiles("your\folder\path").OrderByDescending(Function(f) File.GetCreationTime(f))
datatype of ienumFiles should be IEnumerable(Of String)

If you want all the files from that list to be attached, pass this expression in the attachments

ienumFiles.Select(function(x) LocalResource.FromPath(x))

If you want latest 2 files, use this expression

ienumFiles = Directory.GetFiles("your\folder\path") _
    .OrderByDescending(Function(f) File.GetCreationTime(f)) _
    .Take(2)

Pass this expression in the attachments

ienumFiles.Select(function(x) LocalResource.FromPath(x))

Hi Ashok, I am sure your answer is the solution. Its just to advanced for me. I am unable to put the variable to the datatype IEnumerable(of String) I can only find IEnumerable without string. Maybe thats the reason why UiPath has an issue with “select”
image

@VLC,

You are almost there. Follow these steps

Search this on the next window

System.Collections.Generic.IEnumerable<T>

Then just click ok and you are good

@ashokkarale It has worked indeed. The variable is now correct. Thank you very much!

However the send E-Mail activity still expects and Irecource and says an Ienumerable cant be converted into Irecource