Reputation: 757
I am trying to sending a mail from R using mailR
package but getting the error.
My code :
subject <- "Montly Report"
today<-Sys.Date()
fileName <- sprintf('./DailyReports/LaunchDaily_%s.html', format(today, format = "%d-%m-%y"))
body <- "Testing Document"
send.mail(from = from,
to = to,
cc = cc,
bcc = bcc,
subject = subject,
attach.files = fileName,
html = T,
inline = T,
body = body,
smtp = list(host.name = "smtp.gmail.com", port = 465,
user.name = "email id",
passwd = "password", ssl = TRUE),
authenticate = T,
send = T
)
and error :
Error in .jnew("org.apache.commons.mail.ImageHtmlEmail") :
java.lang.NoClassDefFoundError: javax/activation/DataSource
i have tried to search in google and github also but not getting the fix to the prob.
Note: : Link i have gone through the Link and tried also the code but not worked for me.
System OS : Ubuntu 18.04, R Studio : 1.1.456
Upvotes: 4
Views: 6425
Reputation: 5802
javax.activation
(Java Activation Framework (JAF)) was removed from the core JRE bundle in Java 9. The sendR
library was built against Java 8. You're very likely using a newer version of Java that doesn't have JAF.
Three options:
emayili
The third would be my recommendation.
Upvotes: 0
Reputation: 121
Basically, you want to avoid that kind of dependency bug. I suggest dropping tha package mailR
in favor of emayili
which do not cause that kind of problems.
Upvotes: 1
Reputation: 757
Problem is raised due to the mismatch of Java version error.
For Ubuntu users need to install Oracle Java instead of JDK version and need to set home path properly.
Then google account setting need to be surely lessappsecure to 'turn ON'.
to set java..type in Terminal
sudo add-apt-repository ppa:webupd8team/java
sudo apt update; sudo apt install oracle-java8-installer
javac -version
OUTPUT
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
and test once in R like java path is correctly working or not with rJava
try to run below libraries
library(rJava)
library(mailR)
if both libraries will run without any errors then JAVA is correctly working.
Successful Message :
After completion of sending the mail in r session you will get the message like below :
[1] "Java-Object{org.apache.commons.mail.ImageHtmlEmail@32709393}"
NOTE:
Try to careful while installing and setting the path properly in Ubuntu itself.
Upvotes: 1