preview_mailmerge {mailmerge}R Documentation

Preview mailmerge as shiny gadget in RStudio preview pane.

Description

[Experimental]

Usage

preview_mailmerge(x)

Arguments

x

mailmerge_preview object, from mail_merge

Value

A 'shiny' gadget, see also shiny::runGadget

See Also

mail_merge

Examples

## ---- input-data --------------------------------------------------------

dat <-  data.frame(
  email      = c("friend@example.com", "foe@example.com"),
  first_name = c("friend", "foe"),
  thing      = c("something good", "something bad"),
  stringsAsFactors = FALSE
)

## ---- markdown-message --------------------------------------------------

msg <- '
---
subject: "**Hello, {first_name}**"
---

Hi, **{first_name}**

I am writing to tell you about **{thing}**.

{if (first_name == "friend") "Regards" else ""}


Me
'



## ---- display shiny gadget ----------------------------------------------

if (interactive()) {
  dat %>%
    mail_merge(msg) %>%
    preview_mailmerge()
}




[Package mailmerge version 0.2.5 Index]