Outlook Mail attachment

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.

Hi,

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.

Hey,
I think you can use properties ‘attachmentsCollection’:
image
image
If I remember correctly it’s works fine :slight_smile:

3 Likes

Hi @pandeypriyanka1312

you have to pass argument like this


instead of file name you can pass variable for dynamic attachments
Hope its help you to solve your issue
Thanks,
Robin S

@pandeypriyanka1312

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

image

Please find a small example below

Thank you @pikorpa and @indrajit.shah . Your solution is what I am looking for. It is working now.

Just one more doubt. What if the folder has multiple files and I want to attach few files from the set (files_names will remain same each time)?

1 Like

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

2 Likes

@pandeypriyanka1312

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.

2 Likes

Thank you @pikorpa and @indrajit.shah

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.