首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RDCOMClient + Outlook电子邮件

RDCOMClient + Outlook电子邮件
EN

Stack Overflow用户
提问于 2017-08-27 06:17:01
回答 1查看 5.4K关注 0票数 2

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

唯一的问题是签名;我尝试了在这个链接中给出的指示:

How to add my Outlook email signature to the COM object using RDCOMClient

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

代码语言:javascript
复制
outMail[["HTMLBody"]] = paste0('<p>some body', signature, '</p>')
EN

回答 1

Stack Overflow用户

发布于 2017-11-12 15:17:19

如果这段代码解决了你要找的东西,请告诉我。您需要使用paste命令粘贴带有签名的主体。见下文。

代码语言:javascript
复制
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()

您将收到一封电子邮件,输出如下所示。

解决方案2:由于您没有提供所使用的代码,所以我使用了自己的代码并修复了使用GetInspector时出现的签名问题。如果这有帮助的话请告诉我。

代码语言:javascript
复制
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()
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45902208

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档