Count Attachments in 'SaveMailAttachments' Activity

outlook
activities
attachment

#1

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.


#2

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

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


#4

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


#5

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


#6

@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


#7

@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.


#8

Great


#9