Skip to content

Instantly share code, notes, and snippets.

View tgh0831's full-sized avatar

Thomas Higginbotham tgh0831

  • San Antonio, TX
View GitHub Profile
@tgh0831
tgh0831 / Run SQL Query Then Send XLS with Timestamped Filename Using R.r
Last active October 25, 2016 15:27
This is a simple example to run a query against a Microsoft SQL server, generate an XLS file with a timestamp in the file name, then email that file to selected recipients. The SMTP connection setup works for internal Outlook email that does not require authentication.
##### This will run a query against a Microsoft SQL server,
##### generate an XLS file with a timestamp in the name from the SQL result,
##### then email that XLS file to selected recipients
##### smtp connection works for internal Outlook email not requiring authentication
require(RODBC)
require(xlsx)
require(mailR)
#define the query (insert your query here)