rpremraj / mailR

A utility to send emails from the R programming environment
http://rpremraj.github.io/mailR/
190 stars 57 forks source link

Encoding problem when run r-script out of bat-file #60

Open woldemarg opened 7 years ago

woldemarg commented 7 years ago

Here is a simple script for sending e-mail with a plain text in its body:

library(mailR)

send.mail(
  from = "FROM@gmail.com",
  to = "TO@gmail.com",
  subject = "encoding test",
  body = "тест (ukrainian)\ntest (english)", #plain text in a body of an e-mail
  encoding = "utf-8",
  smtp = list(
    host.name = "smtp.gmail.com",
    port = 465,
    user.name = "myUsername",
    passwd = "myPassword",
    ssl = TRUE
  ),
  authenticate = TRUE,
  send = TRUE
)

Everything works perfect if I run this script out of my RStudio. But when it is started out of bat-file via Rscript an e-mail get messy content:

тест (ukrainian) test (english)

Here is my session info:

sessionInfo()

R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Russian_Russia.1251  LC_CTYPE=Russian_Russia.1251    LC_MONETARY=Russian_Russia.1251
[4] LC_NUMERIC=C                    LC_TIME=Russian_Russia.1251    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] mailR_0.4.1
woldemarg commented 6 years ago

Almost a year on still have no solution for the problem. At least works the following tactics: