-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
291 lines (117 loc) · 4.88 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# mailtoR
<!-- badges: start -->
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/mailtoR)](https://cran.r-project.org/package=mailtoR)
[![CRAN_time_from_release](https://www.r-pkg.org/badges/ago/mailtoR)](https://cran.r-project.org/package=mailtoR)
[![metacran downloads](https://cranlogs.r-pkg.org/badges/mailtoR)](https://cran.r-project.org/package=mailtoR)
[![metacran downloads](https://cranlogs.r-pkg.org/badges/grand-total/mailtoR)](https://cran.r-project.org/package=mailtoR)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://choosealicense.com/licenses/mit/)
[![Travis build status](https://travis-ci.com/feddelegrand7/mailtoR.svg?branch=master)](https://travis-ci.com/feddelegrand7/mailtoR)
[![R badge](https://img.shields.io/badge/Build%20with-♥%20and%20R-pink)](https://github.com/feddelegrand7/mailtoR)
<!-- badges: end -->
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](https://mailtoui.com/#menu) JavaScript library.
## Installation
You can install the `mailtoR` package from [CRAN](https://CRAN.R-project.org/package=mailtoR) with:
```{r, eval=FALSE}
install.packages("mailtoR")
```
You can install the development version of `mailtoR` from Github with:
```{r, eval=FALSE}
# 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__, it activates the features of the [Mailtoui](https://mailtoui.com/#menu) 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:
```{r, eval=FALSE}
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)
```
![](man/figures/mailtoRexample1.gif)
You can use many parameters to configure your email framework:
```{r, eval=FALSE}
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)
```
![](man/figures/mailtoRexample2.gif)
Using the [glue](https://CRAN.R-project.org/package=glue) package, you can ever create a reproducible text report that you'll embed within your email:
```{r, eval=FALSE}
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)
```
![](man/figures/mailtoRexample3.gif)
If you want to send a vector of data you'll need to use `mailtoR` in conjunction with the `jsonlite` package.
```{r, eval=FALSE}
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)
```
![](man/figures/mailtoRexample4.gif)
## Code of Conduct
Please note that the mailtoR project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.