Send Email with Attachments if File exist in folder

Hi,

I am adding send email scenario where I need to attach 3 attachments.Out of 3 , 1 will be always there in folder.
Using o365 we get 2 options to add attachment, and it accepts it as a string only.

  1. Attachments - FileArr(0) and FileArr(1)
  2. Attachments Collection - here I am giving file which is fixed available// this is the output report I am generting , it wil be always there even if there is SE or BE …in transactions

but there can be possibility that FileArr(0) or FileArr(1) not available in folder or both not available or only 1 available. if 2 BE then o file , if 1 BE then 1 file…

I am adding send email in END state of RE framework.

How do I check ? I get obj ref error, or file missing error

Pls help, quite urgent

Hi,

as a solution I am doing below:
I am counting the files in folder.
count is a Int
then, using switch case

Expression: int_FileCount
Default : No files , send email w/o attachment with body informing no files downloaded
1- add , FileArr(0) as an attachment
2- add, FileArr(1) as an attachment

Will this approach work ? due to some reason I am unable to test

@8b6861dc5e0c9f7008548ca66

If in that folder you have only the required files then use System.IO.directory.GetFiles("FolderPath")

This gives all the available files as array whcih can be passed directly in the field attachments

cheers

@Anil_G ,

Thanks for ur reply,

I also have to add 1 file which is in different folder , so shall I concatenate the path ? in Attachments Collection ?what if folder has no file at all System.IO.directory.GetFiles(“FolderPath”) will this work?

For now I have added below:
as a solution I am doing below:
I am counting the files in folder.
count is a Int
then, using switch case

Expression: int_FileCount
Default : 0- No files , send email w/o attachment with body informing no files downloaded
1- add , FileArr(0) as an attachment
2- add, FileArr(1) as an attachment

Will this approach work ? due to some reason I am unable to test

@8b6861dc5e0c9f7008548ca66

Your approach also works…

You can add the extra item also to the list

Using append item to list…so if directory.getfiles return any then item gets added to returned list else item gets added to the empty list…both the ways list of items is created

Cheers