Send respective files from all subfolders to respective emails stored in excel

Hello everyone,

I need to send respective files from multiple subfolders to respective email id present in excel.

@POOJA_MARUTI_BALIGIDE

You can use for each row in datatable if the folder and email is present in excel

inside loop use currentRow("Email").ToString to get the email

and in attachments in send email use Directory.GetFiles(currentRow("FolderPath").ToString)

cheers

@Anil_G ,

The Excel file is having only the client name and client distribution list. and the files are in-array of string variable. file paths contains client name in it.

@POOJA_MARUTI_BALIGIDE

Then to get files with required client name use arrVar.Where(function(x) Path.GetFileName(x).Contains(currentRow("ClientName").ToString))

if the array is containign the fullpath to file…then the above will fitler array and get filepaths where the name is containign the client name

cheers

@Anil_G ,

I am able to get emails but without file attachments.
Its weekly report which is to be send vendors .For some vendors there will not be file/attachment that week.

Please find the attached workflow.Provide your inputs.
mailmsg.xaml (12.2 KB)

@POOJA_MARUTI_BALIGIDE

Can you please tell what you mean without attachments?

Did you happen to use the above provided code to get the attachments?

Any issue in using it?

Cheers

@Anil_G ,
I have to send weekly report to respective clients with attachment
These reports are saved in client subfolders.
While sending an email , i have to attach these report to the respective clients.

@POOJA_MARUTI_BALIGIDE

I get it …to get those files use the above provided code in your loop

Cheers

@Anil_G
attach.Where(function(x) Path.GetFileName(x).Contains(currentRow(“VendorName”).ToString))
used to get attachments. with variable type(Ienumerable).
image.
Not able to get attachments

@POOJA_MARUTI_BALIGIDE

Is attach variable is a array of filepaths ?

And are you getting any error?

Cheers

@Anil_G

Yes attach is array of string containing all files paths from each subfolders.

@tazunnisa.badavide
I have tried it,not working.

@POOJA_MARUTI_BALIGIDE

Okay as per your explanation looks like it is the subfolder that we need to check

so change the formula like this

attach.Where(function(x) x.Contains(currentRow(“VendorName”).ToString))

cheers

@Anil_G ,

Thank you so much. Its working perfect. Able to send report separately to clients.
on below example two reports are going to (FOP@gmail.com)vendor.
image

1 Like

@POOJA_MARUTI_BALIGIDE

Please use this ,which checks the folder name exactly

attach.Where(function(x) new DirectoryInfo(x).Name.ToLower.Equals(currentRow("VendorName").ToString.ToLower.Trim))

cheers

@Anil_G ,
I am getting error when I use this in code.
Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.

attach.Where(function(x) new DirectoryInfo(x).Name.ToLower.Equals(currentRow(“Vendor Name”).ToString.ToLower.Trim))

@POOJA_MARUTI_BALIGIDE

I believe you copy pasted exactly…just readd the inverted comma in the code again around vendorname…

this is correct - "
this is wrong - “

cheers

@Anil_G ,

Its not attaching any attachments .

@POOJA_MARUTI_BALIGIDE

Can you show your folders once…or the filename structure …the folder name is exactly same as vendor name? Or does it start with vendor name or is it containing any other data as well in the name

Cheers

@Anil_G ,

Folder name is same as vendor name.
File name= Vendor Name+“IGR 4600 August 2023.xlsx”