I am trying to crate a workflow for sending mail which can be called from multiple workflows. The values for “To”,“Subject”,“Body” and “Attachment” will be sent as argument.
From the properties section, I understand that attachment should be of type IEnumerable. I am not able to set value for IEnumerable in the calling workflow. Can someone help me with how to pass attachments name as arguments. I want to keep them dynamic.
Could you pls review the below YouTube video explained about how to pass attachment dynamically. I hope you would get some idea on your requirement. Thanks.
you can try the suggestion of @pikorpa, as it’s the best way we can pass multiple attachments to send, instead of using attachments property under Attachments use AttachmentsCollection.
In this way, you have to pass the path of the folder where the attachment will be there and it can attach all the files in the path(you can do it by passing the variable also).
Click on the empty field of AttachemntsCollection and create the variable from there only and upon creating the variable type of the created variable will be of IEnumerable, go to the variable panel and right-click on that variable and select convert to argument, from there go to argument and select the Direction as per your requirement and it’s done
You can create array of string which will be included paths to the file or you can try filter files name like that:
strPath = “C:/ folder /folder name”
arrayFiles (Array Of Strings) = System.IO.Directory.GetFiles(strPath , “*.txt”) - > example for only txt but you can include file name pattern
I would suggest you to keep a seperate folder only for the files you wanna attach to the email, and also to delete or move the files from the folder after attaching and sending the email, this way that folder will be always empty after the bot run/execution
Coming to the point of your questions, in that scenario you have to pass the full file path of the files you wanna attach with file name.
And if you have any specific extension file you wanna attach then @pikorpa has give you the perfect solution.