Attach all files in a folder

Hi All,

Is there a way to attach all files in a folder to an outlook mail without having to specify the file names .

Thanks

1 Like

Hi,

How about first zip all files using
ZipFile.CreateFromDirectory(startPath, zipPath);
ZipFile.ExtractToDirectory(zipPath, extractPath);

and pass the value in"Attach File" property of “Send Outlook Mail Message”

PS:Make sure you import System.IO.Compression.FileSystem manually.

1 Like

Besides Dilip’s solution, if your channel has blocked zip formats you may try below solution, I assume it should work for outlook as well.

Compress has thrown an exception

Message: Access to the path 'C:\Users' is denied.

Source: Assign

Exception Type: UnauthorizedAccessException

@ddpadil

I have the file system imported:

I am trying the following :slight_smile:

What should be the variable type for this Assign ,

I am getting an error saying ZipFile is not declared

You can try this.

You need to open your .XAML file in notepad, search for AssemblyReference where you will see all the Namespaces imported to your workflow. At the end add a Tag

Even your code should work after you add the reference.

<AssemblyReference>System.IO.Compression.FileSystem</AssemblyReference>

I added the Assembly ref code to the Xaml file, but get the following error.

Compress (2) has thrown an exception

Message: Access to the path 'C:\Users' is denied.

Source: Assign

Exception Type: UnauthorizedAccessException

System.UnauthorizedAccessException: Access to the path 'C:\Users' is denied.

Variable type for assign should be zip:System.IO.Compression.ZipArchive
Regarding error.
Hope your having admin privileges please change the workflow directly and give a try.

Use Outlook Mail Message, and add AttachmentsCollection this Directory.GetFiles(“url”)

image

3 Likes

This is a simple yet efficient solution for the problem.

1 Like