2015-05-09 21 views
16

R-generated HTML raporlarını e-posta yoluyla satır içi (ek olarak değil) göndermek için gmailR paketini kullanmak istiyorum. gmailr'u kullanarak temel bir HTML e-postası bile gönderemiyorum. Ben başarısız aşağıdaki teşebbüs ve biraz yardıma ihtiyacım var:gmailr kullanarak HTML mesajı gönder

library(gmailr) 
gmail_auth("oauth.token.json", scope = "compose") 

test_email <- mime() %>% 
to("[email protected]") %>% 
from("[email protected]") %>% 
subject("This is a subject") 
test_email$body <- "I wish <b>this</b> was bold" 
send_message(test_email) 
SONUÇ: Mesaj başarıyla gönderir, ancak vücut düz metindir - değil HTML


Denemesi 2

test_email <- mime() %>% 
to("[email protected]") %>% 
from("[email protected]") %>% 
subject("This is a subject") %>% 
html_body("I wish <b>this</b> was bold") 
test_email$body 
SONUÇ: test_email $ body NULL


Denemesi 3

test_email <- mime() %>% 
to("[email protected]") %>% 
from("[email protected]") %>% 
    subject("This is a subject") 
test_email$body <- html_body("I wish <b>this</b> was bold") 
Sonuç: mim $ parçaları hata: Hata: $ operatör atom vektörleri


Denemesi 4

test_email <- mime() %>% 
to("[email protected]") %>% 
from("[email protected]") %>% 
subject("This is a subject") 
test_email$parts <- c(html_body("I wish <b>this</b> was bold"),text_body("plain")) 
SONUÇ için geçersiz Mime $ parça: $ operatörü atomik vektörler 01 için geçersiz <html> ve <body> dahil - - için

library(gmailr) 
gmail_auth('mysecret.json', scope = 'compose') 

test_email <- mime() %>% 
to("[email protected]") %>% 
from("[email protected]") %>% 
subject("This is a subject") %>% 
html_body("<html><body>I wish <b>this</b> was bold</body></html>") 
send_message(test_email) 

Ve işte (Alman gmail ...) hüner gerçek HTML koymak içindi gibi enter image description here

görünüyor: -

+1

bunun burada başvurulan sorunla ilgili olduğu anlaşılmaktadır: https://github.com/jimhester/gmailr/issues/9 –

+0

Bu, gmail ile ilgili sorununuzu yanıtlamıyor olsa da, mailR'ye bir çekim yapmanızı öneririm HTML formatlı e-postaları kolayca gönderir (https://github.com/rpremraj/mailR). –

+0

3 ve 4 girişimleri açıkça geçersizdir. Belgeler belirttiği gibi, text_body() ve html_body() için ilk argümanlar bir metin dizesi değil, bir mime nesnesidir. Bir mime nesnesinde html veya metin gövdesini ayarlamak için kullanılabilir, örneğin: text_body (test_email, "Düz metin dizgisi") – WhiteViking

cevap

2

Eh bu Denedim budur gmail'i anla.

İlgili konular