Skip to content

๐Ÿน๐Ÿน๐Ÿน Creates a Friendly User Interface for Emails Sending in Shiny and RMarkdown

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE.md
Notifications You must be signed in to change notification settings

feddelegrand7/mailtoR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

mailtoR

CRAN_Status_Badge

CRAN_time_from_release

metacran downloads

metacran downloads

license

Travis build status

R badge

The goal of mailtoR is to implement a personalized user interface for emails sending within your Shiny applications and/or RMarkdown documents. Itโ€™s a wrapper of the Mailtoui JavaScript library.

Installation

You can install the mailtoR package from CRAN with:

install.packages("mailtoR")

You can install the development version of mailtoR from Github with:

# install.packages("remotes")

remotes::install_github("feddelegrand7/mailtoR")

How to use the package

The mailtoR package is composed of two functions:

  • use_mailtoR(): put this function at the end of your Shiny ui (doesn't matter in RMarkdown), it activates the features of the Mailtoui library;

  • mailtoR(): use this function to create as many email links as you want (see examples below)

The following examples are provided in Shiny coding however the principles remain the same for RMarkdown documents.

Examples:

library(shiny)
library(mailtoR)

ui <- fluidPage(



  mailtoR(email = "[email protected]",
          text = "Click here to send an email !"),


  use_mailtoR()


)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

You can use many parameters to configure your email framework:

library(shiny)
library(mailtoR)

ui <- fluidPage(



  mailtoR(email = "[email protected]",
          text = "click here to send an email", 
          subject = "URGENT", 
          cc = c("[email protected]", "[email protected]"), 
          body = "Hi Michaels, it's David Wallace, your branch needs to make more sales !!!!!!!"),


  use_mailtoR()


)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

Using the glue package, you can ever create a reproducible text report that youโ€™ll embed within your email:

library(shiny)
library(mailtoR)

ui <- fluidPage(



  mailtoR(email = "[email protected]",
          text = "click here to send an email", 
          subject = "Useful Information", 
          body = glue::glue(
          
          "
Hi,
          
Did you know that the mtcars dataset has {nrow(mtcars)} rows and {ncol(mtcars)} columns ? 
            
Best regards. 
            
            "
            
            
            
          )),


  use_mailtoR()


)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

If you want to send a vector of data youโ€™ll need to use mailtoR in conjunction with the jsonlite package.

library(shiny)
library(mailtoR)
library(jsonlite)


# converting our data to JSON format

vec <- toJSON(mtcars$mpg)

# reformat our results to make it prettier 

vec_pretty <- prettify(vec)


ui <- fluidPage(

  mailtoR(email = "[email protected]",
          text = "click here to send an email", 
          subject = "Useful Information", 
          body = glue::glue(
          
          "
Hi,
          

Below you'll find the mpg column of the mtcars data frame: 

{vec_pretty}

Best regards
            
            "
            
          )),


  use_mailtoR()


)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

Code of Conduct

Please note that the mailtoR project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.