embedrdcomclientoft

How can I insert an OFT template on an Outlook message using RDComClient?


I wanto to embed or insert a premade oft template on message but I dont knon how can I do it. Im able to embed images, but I need to insert complex html compatible with outlook

I have this parte done I can embed image but no html


 Open Outlook
Outlook <- COMCreate("Outlook.Application")

# Create a new message
Email = Outlook$CreateItem(0)



# Attach
Email[["attachments"]]$Add("PDFS/genericos/CG_GMMC.pdf")
Email[["attachments"]]$Add("PDFS/genericos/Guia_de_Acompanamiento_2023.pdf")
Email[["attachments"]]$Add(paste0("zips/poliza",base_cruzada_p_envio$numcertceros[c],".zip"))
Email[["attachments"]]$Add("html/AXA_Assistance_com.jpg")
Email[["attachments"]]$Add("html/html.oft")


imageninsert <- paste0("<img src='cid:AXA_Assistance_com.jpg' width='600' height='833' alt='Tu poliza ha sido renovada'>")

htmlinsert <- paste0("<img src='cid:html.oft' width='600' height='833' alt='Tu poliza ha sido renovada'>")



# Set the recipient, subject, and body
Email[["to"]] = base_cruzada_p_envio$Correo[c]
#Email[["cc"]] = ""
#Email[["bcc"]] = ""
Email[["subject"]] = "¡Tu póliza de GMM ha sido renovada!"
Email[["HTMLbody"]] =
paste0(imageninsert)

#Check info
Email$Display()
}
# Send
Email$Send()

#le damos un tiempo para que outlook le de tiempo de hacer el envio 14 es lo adecuado pero puede variar
Sys.sleep(14.0)
# Close Outlook, clear the message
rm(Outlook, Email)


Solution

  • I got to resolve like this contenido_html <- readLines("path/html_test.html", encoding = "UTF-8",warn=FALSE) Email[["HTMLbody"]] = paste(contenido_html, collapse = "\n")