ファイル名を取得後outlookでメール送信

お世話になっております。

指定フォルダ内の全ての.xlsxファイルのファイル名を取得し、取得したファイル名をoutlookでメール送信したいです。

変数でエラーが出てしまいます。ファイル名取得時の変数の型と、メール本文に入力する変数の型を教えていただけますでしょうか。

よろしくお願いいたします。

Hi @t.jewelry.swarovski

Try this syntax:

filesInFolder = Directory.GetFiles("C:\Your\Folder\Path", "*.xlsx").Select(Function(filePath) Path.GetFileName(filePath)).ToList()

filesInFolder is of DataType List(System.String)

To print output use the below syntax:

String.Join(Environment.NewLine, filesInFolder)

Hope it helps!!

Hi @t.jewelry.swarovski

xlsxFiles = Directory.GetFiles("C:\Users\YoutFolderPath", "*.xlsx").Select(Function(filePath) Path.GetFileNameWithoutExtension(filePath)).ToArray()
emailBody = String.Join(Environment.NewLine, xlsxFiles)

Regards,

@t.jewelry.swarovski

filesArray = Directory.GetFiles("YourFolderPath", "*.xlsx")
String.Join(Environment.NewLine, filesArray)

Hi @t.jewelry.swarovski

To get all the .xlsx files in array of string :
arr_Paths = Directory.GetFiles("C:\Your\Folder\Path", "*.xlsx")

Getting file names without extensions into an array of string:
fileNamesWithoutExtensions = arr_Paths.Select(Function(fileName) Path.GetFileNameWithoutExtension(fileName)).

Join all the file names as comma separated
str_emailBody = String.Join(", ", fileNamesWithoutExtensions)