使用mailR发送电子邮件时如何正确显示汉字?

时间:2019-07-18 10:53:11

标签: character-encoding

我使用以下脚本发送电子邮件。可以。

library(mailR)
myfrom<-"from@example.com"
mysmtp<-"smtp.example.com"
mysmtpport<-25
myusername<-"emailfromusername"
mypassword<-"emailaccountpassword"

myemailsubject<- "The Subject"
myemailcontent="content of the email"

emailto<-"emailto@example.com"

send.mail(from = myfrom,
          to = emailto,
          replyTo= myfrom,
          subject = myemailsubject,
          body = emailbody,
          html = TRUE,
          encoding="utf-8",
          smtp = list(host.name = mysmtp, port = mysmtpport, user.name = myusername, passwd = mypassword, ssl = FALSE,tsl= FALSE),
          authenticate = TRUE,
          send = TRUE)

但是,如果我在myfrom中插入一些汉字,就像myfrom <-“大家好”。这些汉字显示不正确。

我尝试过:

myfrom<-"大家好 < from@example.com >"
Encoding(myfrom)<-"utf-8"

还是没用。如何正确显示这些汉字?有什么建议么?谢谢。

0 个答案:

没有答案