<- "Yes"
condition_met
if (condition_met == "Yes") {
# If there are duplicates, notify by email
library(Microsoft365R)
# Authenticate and create Outlook object
<- get_business_outlook() # or get_personal_outlook()
outlook
# Create email
<- outlook$create_email(
email body = "Condition was met in automated workflow. Review and revise code for data QA check.",
subject = "Condition met in automted workflow",
to = "outlook-exchange-email@organization.edu"
)
# Send email
$send()
email
# Stop the render
stop("Error in .qmd file. Condition was met")
}
Outlook Notification Emails
Some projects I work on have reports or tasks that are automated in R and scheduled to run on a regular basis. However, some of these tasks may encounter an error from time to time. Perhaps the taks encountered an edge case and caused the script to crash. In R, it is relatively easy to configure the script to send an email when a user-defined condition is met to promptly address these situations. The following code chunk accomplishes this for those with a Microsoft Outlook based email system.