RDCOMClient+;Outlook电子邮件

RDCOMClient+;Outlook电子邮件,r,outlook,rdcomclient,R,Outlook,Rdcomclient,我试图通过R代码从outlook发送电子邮件。它在很大程度上运行良好。我正在使用RDCOMClient做我需要的事情 唯一的问题是签名;我尝试了此链接中给出的说明: 但是,我的签名会被这一行的电子邮件正文覆盖: outMail[["HTMLBody"]] = paste0('<p>some body', signature, '</p>') outMail[[“HTMLBody”]=paste0(“somebody”,签名“”) 请告诉我此代码是否解决了您需要的问题。

我试图通过R代码从outlook发送电子邮件。它在很大程度上运行良好。我正在使用RDCOMClient做我需要的事情

唯一的问题是签名;我尝试了此链接中给出的说明:

但是,我的签名会被这一行的电子邮件正文覆盖:

outMail[["HTMLBody"]] = paste0('<p>some body', signature, '</p>')
outMail[[“HTMLBody”]=paste0(“somebody”,签名“

”)
请告诉我此代码是否解决了您需要的问题。您需要使用
paste
命令粘贴带有签名的正文。见下文

library(RDCOMClient)

# This is the original body you have created
original_body <- "This body has been created to just for visualization"
# Adding signature which can be modified as required
# The <br> is html tag for line break. Anything typed after this will move to next line
Your_Signature <- paste0("Thanks & Regards,<br>", "YourName")
# Creating new body which will be used in email
new_body <- paste("<p>",original_body, "</p>", Your_Signature)

# init com api
OutApp <- COMCreate("Outlook.Application")
# create an email 
outMail = OutApp$CreateItem(0)
# configure  email parameter 
outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "TEST"
outMail[["HTMLbody"]] = new_body
# send it                     
outMail$Send()
library(RDCOMClient)

OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)

# Get signature from outlook
# GetInspector renders the message in html format.
# Note that if you have not created any signatures, this will return blank
outMail$GetInspector()
Signature <- outMail[["HTMLbody"]]

# Define the body of you email separately
body <- "Define your body here."

outMail[["To"]] = "test@test.com"
outMail[["subject"]] = "TEST EMAIL"

# Paste the body and signatures into the email body
outMail[["HTMLbody"]] = paste0("<p>", body, "</p>", Signature)
outMail$Send()