无法通过电子邮件发送使用RMarkdown生成的html报告

时间:2016-11-16 02:20:04

标签: r knitr r-markdown

我使用R markdown生成了一个html报告。现在我想通过电子邮件发送此报告, 我正在使用以下代码发送电子邮件。

   library(rmarkdown)
         library(mailR)
      #    rmarkdown::render("test_kable.Rmd")


         sendmail(
           from = "abc@xyz.com",
           to = "xyz@xyz.com",
           subject = "R Markdown Report - rmarkdown",
           html = T,
           inline = T,

           body = "test_kable.html",
           attach.files = "./test_kable.html",
           msg <- "./test_kable.html",
           smtp = list(
             host.name = "smtp1.servername.com", 
            # port = 465, 
            # user.name = "me",    
            # passwd = "password", 
             ssl = T),
           authenticate = T,
           send = T)         

我能够成功发送电子邮件,但呈现的html文件不在电子邮件中。

我尝试了多个选项,但是电子邮件正文总是包含我在正文中传递的内容。 即使我试图附加渲染的html文件(它在同一工作目录中),但我从未在电子邮件中获得附件。 这是我的.RMD文件的标题,我也使用一些CSS格式来格式化文件中生成的表格。

  ---
    title: "ODS to AppDS data comparision"
    author: "Ravindra Kumar"
    date: "November 11, 2016"
    output: 
      html_document:
        toc: true
        css: ink.css
        self_contained: no

    ---

会话信息 -

R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

请提出任何建议。

编辑 - 当我使用readLine时,我收到的电子邮件就像这样

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="generator" content="pandoc" />


<meta name="author" content="Ravindra Kumar" />

<meta name="date" content="2016-11-11" />

<title>ODS to AppDS data comparision</title>

<script src="test_kable_files/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="test_kable_files/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" /> <script src="test_kable_files/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="test_kable_files/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="test_kable_files/bootstrap-3.3.5/shim/respond.min.js"></script>

<style type="text/css">code{white-space: pre;}</style> <link rel="stylesheet"
      href="test_kable_files/highlight/default.css"
      type="text/css" />
<script src="test_kable_files/highlight/highlight.js"></script>
<style type="text/css">
  pre:not([class]) {
    background-color: white;
  }
</style>
<script type="text/javascript">
if (window.hljs && document.readyState && document.readyState === "complete") {
   window.setTimeout(function() {
      hljs.initHighlighting();
   }, 0);
}
</script>



<style type="text/css">
h1 {
  font-size: 34px;
}
h1.title {
  font-size: 38px;
}
h2 {
  font-size: 30px;
}
h3 {
  font-size: 24px;
}
h4 {
  font-size: 18px;
}
h5 {
  font-size: 16px;
}
h6 {
  font-size: 12px;
}
table th:not([align]) {
  text-align: left;
}
</style>

<link rel="stylesheet" href="ink.css" type="text/css" />

</head>

0 个答案:

没有答案