如何使用RDCOMClient将我的Outlook电子邮件签名添加到COM对象

时间:2016-06-16 21:34:36

标签: r com outlook rdcomclient

我正在研究RDCOMClient到我的一些工作流程并感谢agstudy的回答Here我能够发送电子邮件,但我无法弄清楚如何添加我的Outlook电子邮件签名。我是COM对象的新手,但已经做了相当多的搜索并且没有找到任何东西。因为我的声誉尚未达到50,我无法评论那里的初始线索。有人可以告诉我如何添加我的Outlook电子邮件签名吗?

library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application") 
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "dest@dest.com"
outMail[["subject"]] = "some subject"
outMail[["body"]] = "some body"
## I want to add my outlook signature here.                     
outMail$Send()

1 个答案:

答案 0 :(得分:7)

考虑使用Outlook的GetInspector()属性。假设您有自动签名,请指定一个变量来捕获默认正文,然后连接到后一个消息:

library(RDCOMClient)

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

outMail$GetInspector()
signature = outMail[["HTMLBody"]]

outMail[["Recipients"]]$Add("dest@dest.com")
outMail[["Subject"]] = "some subject"
outMail[["HTMLBody"]] = paste0('<p>some body', signature, '</p>')

outMail$Display()
outMail <- NULL
OutApp <- NULL