Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a table in PowerBi with an R script for exporting on the local pc. Every week the table changed to the previous week.
The R script exports a CSV on the local pc with the name of the week of the column in the table.
Example: TEST 01-2024, TEST 02-2024 etc.
# 'dataset' holds the input data for this script
week <- unique(dataset$Week) - 1
year <- format(Sys.time(), "%Y")
Table <- paste0("\\\\af01\\Users\\Tinus\\Desktop\\new\\TEST ", week, "-", year, ".csv")
write.table(dataset, file = Table, sep = ";", na = "", row.names = FALSE, quote = FALSE)
Email R script is no problem but how can I change the R script so that the attachment is the Export from the above R script.
library(mailR)
send.mail(from = "user@sender.com",
to = "user@recipient.com",
subject = "Test email subject",
body = "Test emails body",
smtp = list(host.name = "smtp.mailtrap.io", port = 25,
user.name = "********",
passwd = "******", ssl = TRUE),
authenticate = TRUE,
send = TRUE)
There are multible files in the folder so just add "attach.files" in the R script does not solve the problem.
I also tried another solution, for example: Power Automate. But I cant found a solution that exports the file on the local pc.
Many thanks.
Solved! Go to Solution.
I find the solution.
script_files <- list.files(path = folder_path, pattern = "\\.csv$", full.names = TRUE)
I find the solution.
script_files <- list.files(path = folder_path, pattern = "\\.csv$", full.names = TRUE)
Hi @Tinus1905
You can refer to thef following link.
R: Source R files in an attached environment (r-project.org)
Sending Email Attachement Through Outlook in R with RDCOMClient - Stack Overflow
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous ; I read the article but I don't know how to use that in my R scripts.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 17 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |