rstudio / blastula

Easily send great-looking HTML email messages from R
https://pkgs.rstudio.com/blastula
Other
548 stars 85 forks source link

Different mail rendering Outlook vs Gmail #289

Closed ScaonE closed 1 year ago

ScaonE commented 2 years ago

Dear all,

I'm trying to use Microsoft365R + blastula to send emails. The goal is to have nice Outlook integration + R Markdown document for a richer email.

When testing, the blastula::render_email() displays fine in RStudio viewer pane:

Viewer

viewer

Then, when sending with Microsoft365R send() method, the resulting mail looks as exepected in the Outlook inbox, but is kinda ugly in Gmail (e.g. css defined elements aren't working): (I don't know in advance to whom I'll have to send these kind of emails, thus I have to test with a few widely used mail services)

Outlook

outlook

Gmail

gmail

=> Any tips on how to fix this?

Here is what I tried without success:

In the create_email() method options, set content_type = "text".

Here is what I read about Gmail which might explain stuff:

=> Is there an equivalent of include_css = "rmd" in blastula?

Code for reproducibility:

template.Rmd

---
title: "Report"
output:
  blastula::blastula_email
--- 

```{r, include = FALSE}
library(knitr)
library(showtext)
font_add_google("Montserrat")
h2 {
  font-size: 20px;
  font-family: "Montserrat";
  text-align: left;
  color: #ff0000;
}

.contact {
  font-family: "Montserrat";
  font-size: 12px;
  color: #ff0000;
  padding-left: 10px;
  border-left: 1px solid #ff0000;
  margin-left: 100px;
  text-align: left;
}
## My title

Dear all,

My text *toto*
```{r, echo = FALSE, out.width = 80, fig.align='right', out.extra='style="float: left; position: relative; top: 30px"'}
knitr::include_graphics("https://www.datanovia.com/en/wp-content/uploads/dn-tutorials/r-tutorial/images/boxplot-icon-sticker.png")

<p class = "contact">
Contact:  
**Organisation**<br>
  toto<br>
  FRANCE<br>
  <br>
  toto@biofortis.fr<br>
</p>

main.R

library(Microsoft365R)
library(blastula)

outlook <- get_business_outlook()

blast_mail <- render_email("template.Rmd")

btoc_mail <-
  outlook$create_email(
    body = blast_mail,
    content_type = "html",
    subject = "Your custom mail",
    to = "erwann.scaon@biofortis.fr",
    cc = "erwan.scaon@gmail.com",
    send_now = FALSE
  )

btoc_mail$send()
datawookie commented 2 years ago

Hi @ScaonE, although it's possible to work with {blastula} and {emayili} on the same project, I don't believe that this is ideal. I'd suggest choosing one package or the other. With regards to CSS in Gmail, this is a well known issue. I am having some success with styling HTML messages in {emayili} and I'm sure that it should be possible in {blastula} too (but I'm not sure how). Thanks, Andrew.

ScaonE commented 2 years ago

Hi @ScaonE, although it's possible to work with {blastula} and {emayili} on the same project, I don't believe that this is ideal.

I do agree, I only used blastula up to now. I was only quoting a part of emayili documentation which refers to Gmail & potential CSS issues.

With regards to CSS in Gmail, this is a well known issue. I am having some success with styling HTML messages in {emayili}

I glad to hear it. Any minimal reproducible exemple available ?

Thanks for you reply btw

rich-iannone commented 1 year ago

Sorry for the late reply, I don't think it's possible to successfully combine Microsoft365R with blastula (it was never tested to work together). I'd would try composing the message and sending it entirely with blastula.