rpremraj / mailR

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

Can't send email with complex HTML body using mailR #80

Open laresbernardo opened 5 years ago

laresbernardo commented 5 years ago

I am trying to send an email with HTML body generated from RMarkdown. I have sent this file as attachment and works just fine but I need it into the body.

The error I get is the following:

org.apache.commons.mail.EmailException: Building the MimeMessage failed
    at org.apache.commons.mail.ImageHtmlEmail.buildMimeMessage(ImageHtmlEmail.java:112)
    at org.apache.commons.mail.Email.send(Email.java:1436)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at RJavaTools.invokeMethod(RJavaTools.java:386)
Caused by: java.io.IOException: Cant resolve the following file resource :

...

Attached HTML file used (inside the ZIP)

Hope you guys can help me!

report.html.zip

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] config_0.3       mailR_0.4.1      kableExtra_0.9.0 knitr_1.20      
 [5] rmarkdown_1.10   gridExtra_2.3    scales_1.0.0     ggplot2_3.0.0   
 [9] bindrcpp_0.2.2   jsonlite_1.5     lubridate_1.7.4  dplyr_0.7.6     
[13] quantmod_0.4-13  TTR_0.23-3       xts_0.11-0       zoo_1.8-2       
[17] rdrop2_0.8.1     openxlsx_4.1.0   lares_4.1       

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.19.2             lattice_0.20-35           
 [3] assertive.properties_0.0-4 assertive.types_0.0-3     
 [5] assertive.data.us_0.0-1    assertthat_0.2.0          
 [7] rprojroot_1.3-2            digest_0.6.17             
 [9] R6_2.3.0                   plyr_1.8.4                
[11] backports_1.1.2            evaluate_0.10.1           
[13] assertive.code_0.0-1       highr_0.7                 
[15] httr_1.3.1                 pillar_1.2.3              
[17] assertive.strings_0.0-3    rlang_0.2.2               
[19] lazyeval_0.2.1             curl_3.2                  
[21] rstudioapi_0.8             R.oo_1.22.0               
[23] R.utils_2.6.0              assertive_0.3-5           
[25] assertive.data_0.0-1       labeling_0.3              
[27] readr_1.1.1                stringr_1.3.1             
[29] munsell_0.5.0              compiler_3.5.1            
[31] pkgconfig_2.0.2            htmltools_0.3.6           
[33] tidyselect_0.2.4           tibble_1.4.2              
[35] assertive.sets_0.0-3       codetools_0.2-15          
[37] viridisLite_0.3.0          withr_2.1.2               
[39] R.methodsS3_1.7.1          assertive.base_0.0-7      
[41] gtable_0.2.0               magrittr_1.5              
[43] assertive.models_0.0-1     zip_1.0.0                 
[45] stringi_1.2.3              reshape2_1.4.3            
[47] assertive.matrices_0.0-1   xml2_1.2.0                
[49] assertive.reflection_0.0-4 assertive.datetimes_0.0-2 
[51] tools_3.5.1                glue_1.2.0                
[53] purrr_0.2.5                assertive.numbers_0.0-2   
[55] hms_0.4.2                  yaml_2.2.0                
[57] colorspace_1.3-2           assertive.files_0.0-2     
[59] assertive.data.uk_0.0-1    rvest_0.3.2               
[61] rJava_0.9-10               bindr_0.1.1    
McCompexpert commented 5 years ago

Same behaviour here - cannot send html in email body, only as an attachment. Do we have an idea how to workaround?