```
# mail to your email: mailR package
library(mailR)
# 发件人
sender <- "10@163.com" # Replace with a valid address
# 收件人
recipients <- c("21@qq.com") # Replace with one or more valid addresses
# 邮件主题
emailSubject <- "send email with R"
# 邮件内容
emailBody <- "成功发送"
# 邮件附件 这个可以用c(,,,,)发送多个附件!
emailFile <- "C:/Users/xx/Documents/R_Project/APExBIO/test_rmarkdown/rmarkdown_test.Rmd"
# 发送邮件
send.mail(from = sender,
to = recipients,
subject = emailSubject,
body = emailBody,
smtp = list(host.name="smtp.163.com", # smtp 服务器主机名
port=465, # 默认端口
user.name=sender, # 用户名
passwd="xxx", # 个人密码
ssl=TRUE),
authenticate = TRUE,
send = TRUE,
attach.files = emailFile,
encoding = "utf-8" # 编码
)
```
问题:java版本引起mailR包没法运行
## 出现: Error in .jnew("org.apache.commons.mail.MultiPartEmail") : java.lang.NoClassDefFoundError: javax/activation/DataSour
### 解决方法:
1. 下载 jar文件:
https://mvnrepository.com/artifact/javax.activation/javax.activation-api/1.2.0
https://mvnrepository.com/artifact/com.sun.activation/javax.activation/1.2.0
2.system.file("java", package = "mailR") 找到安装包位置 C:\Users\xx\Documents\R\win-library\4.0\mailR\java\
3. 将下载的两个文件copy到文件夹下;
可以存在两种4. 重启rstudio即可。
网友评论