お世話になっております。
指定フォルダ内の全ての.xlsxファイルのファイル名を取得し、取得したファイル名をoutlookでメール送信したいです。
変数でエラーが出てしまいます。ファイル名取得時の変数の型と、メール本文に入力する変数の型を教えていただけますでしょうか。
よろしくお願いいたします。
お世話になっております。
指定フォルダ内の全ての.xlsxファイルのファイル名を取得し、取得したファイル名をoutlookでメール送信したいです。
変数でエラーが出てしまいます。ファイル名取得時の変数の型と、メール本文に入力する変数の型を教えていただけますでしょうか。
よろしくお願いいたします。
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!!
xlsxFiles = Directory.GetFiles("C:\Users\YoutFolderPath", "*.xlsx").Select(Function(filePath) Path.GetFileNameWithoutExtension(filePath)).ToArray()
emailBody = String.Join(Environment.NewLine, xlsxFiles)
Regards,
filesArray = Directory.GetFiles("YourFolderPath", "*.xlsx")
String.Join(Environment.NewLine, filesArray)
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)