Count Attachments in 'SaveMailAttachments' Activity

Hi, I am trying to create a variable for the ‘Output’ property of the ‘Save Attachments’ activity so that I can do a count of the number of attachments that were save in that activity. I have created a variable named ‘AllAttachments’ but I’m not sure what to make the variable type so that it can convert it to a systems.collections.generic.ienumerable(of string) type.

All I want to do here is get a count of the attachments that were saved in the save attachments activity. Any help would be greatly appreciated. Thanks all.

You could assign the Output the following, which counts the number of files in the directory:

directory.GetFiles(in_StrFileDirectory).count

This could require you to put in your directory to which they’re being saved. If there are already other files in there you could differentiate by adding a specifier after in_StrFileDirectory, such as:

(in_StrFileDirectory, “*.pdf”) for example

Hope this helps, although I appreciate it’s not the direct way of achieving what you’re after.

3 Likes

Hi,
you can use Directory.GetFiles(FileAttachmentsPath).Count here FileAttachment is the path of the folder where you have saved your files.
Thanks.

1 Like

Thank you Alex. That did the trick. Sorry, don’t know why I didn’t think of this before.

Thanks Uthraa. You solution is the same as Alex’s and works perfectly

1 Like

@kennyjameslynn If your requirement is to check only the count of attachments in an email, you dont need to save them into your system. You can directly check
mailMessage

mailMessage.Attachments.Count

If your requirement is downloading the attachment and then checking the count of attachment, then you can follow the steps specified by @Alex_Cross

2 Likes

@Madhavi Thanks but my requirement is to download the attachments from Outlook and display a count of those attachments at the end of the process so the user knows how many were saved and to where. @Alex_Cross solution was perfect for my requirements.

2 Likes

Great