I have an R script that runs an SQL query and saves the output in .xlxs format with the date and time in the file name. Hence, the file names in the directory are unique.
Whenever the query result is greater than 0, I would also like to email the file as an attachment. What is the simplest way to accomplish this?
Since the file names are unique, is attaching the newest file in the directory the best or only way to do this? I am able to identify the newest file with:
df <- file.info(list.files("\\file\path\", full.name = T)) rownames (df) [which.max(df$mtime)]
However, I don't know how to successfully combine it with "attached.file =". Is that even possible or is there a better way? Please help! Thank you!