blastula icon indicating copy to clipboard operation
blastula copied to clipboard

Different mail rendering Outlook vs Gmail

Open ScaonE opened this issue 2 years ago • 2 comments

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:

  • Gmail clips emails exceeding a file size of 102KB.

  • From the emayili doc:

Note: Gmail doesn’t like the Bootstrap CSS. If you want your styling to work on Gmail you should set include_css = c("rmd", "highlight").

=> 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>
  [email protected]<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 = "[email protected]",
    cc = "[email protected]",
    send_now = FALSE
  )

btoc_mail$send()

ScaonE avatar Jun 20 '22 13:06 ScaonE

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.

datawookie avatar Jun 20 '22 14:06 datawookie

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

ScaonE avatar Jun 20 '22 14:06 ScaonE

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.

rich-iannone avatar Apr 03 '23 23:04 rich-iannone