Option to attach array (string) in send mail for attachment

We for now, we can pass file name as a string in send mail option. So incase I have array (n number of files in folder), I can’t send it. it would be really great if I can pass array in send mail (attachment) option

2 Likes

Usually it helps to also give broader information about what you are trying to achieve, like what type of data are you trying to send, and what for.

But since email is not a medium that actually supports arrays, you can easily send them as a joined string.

String.Join(“,”, new string {“a”, “b”, “c”});

or for ints

int integers = new int { 1,2,3,4,5 };
String.Join(“,”, Array.ConvertAll<int, String>(integers, Convert.ToString));

1 Like

Sorry, if I was not clear! What I was trying to achieve is attach all the files in folder. The number of files in folder might vary. So, I was trying to see if I can pass the list of file (array) in activity “Send Mail” option - attachment :slight_smile: as an array type arguments, instead of string type argument. I will try your string. Join option, but I have my doubts

Hi @MGDEL,
I got your problem, I guess there is no option to add variable files in attachment command…

I have turnaround to it.if useful happy

Use this Invoke Method to Zip the specified folder which contains all the files to be attached…

After which you can add that Zip in attachment…it is one way of doing it.

Plz be revert with the response…:slight_smile:

1 Like

May not apply to you, I had the same requirement and zip format is filtered out so I created 6 variables in attach files and iterate the directory files (for each) and attach the path to the variables and send email (file count is <= 6)

incase if less than 6, I have attached a dummy file which user is aware of it and will be ignored.

1 Like

Thanks for this idea! I did the same for my use case :)! the reason for asking this functionality was to send files without zipping it!

Apart from the zip file method above, one can create a Mail object and then loop through all the files in a folder and attach it to the mail object using Mail.Attachments.Add and then assign this mail object in the send activity.

2 Likes

Can you share XAML for this? I am not sure how to get create a mail object.

Please find the xaml file example.

Main.xaml (13.1 KB)

2 Likes

Hello all,

I am thinking that maybe a for each file activity on a directory.getfiles would be the best choice.

regards.

HI @Sachin_Desai Regarding attaching multiple files in email (in your workflow), the ‘attach files’ property only accepts string, how do we include mail.attachments in that property. Pls advice.

Few weeks ago I fount this treasure posted on the forum on another thread… It doesn’t quite solve the request with sending file names as an array but it attaches files in a given folder…

send_mail_att_folder.xaml (13.1 KB)

1 Like