Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am working RDCOMClient into some of my work flow and thanks to agstudy's answer Here I am able to send emails throuhg r, but I can't figure out how to add my Outlook email signature. I'm new to COM objects, but have done a fair share of searching and haven't found anything. Because my reputation hasn't hit 50 yet, I wasn't able to comment on the inital thread to ask there. Can someone show me how I can add my Outlook email signature?

library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application") 
outMail = OutApp$CreateItem(0)
outMail[["To"]] = "[email protected]"
outMail[["subject"]] = "some subject"
outMail[["body"]] = "some body"
## I want to add my outlook signature here.                     
outMail$Send()
like image 443
Ben Avatar asked Jun 16 '16 21:06

Ben


Video Answer


1 Answers

Consider using Outlook's GetInspector() property. Assuming you have an auto-signature, assign a variable to capture the default body and then concatenate to your latter message:

library(RDCOMClient)

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

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

outMail[["Recipients"]]$Add("[email protected]")
outMail[["Subject"]] = "some subject"
outMail[["HTMLBody"]] = paste0('<p>some body', signature, '</p>')

outMail$Display()
outMail <- NULL
OutApp <- NULL
like image 61
Parfait Avatar answered Sep 22 '22 11:09

Parfait