remailrdcomclient

Sending emails in R without outlook app in the system


I'm able to send emails using the following code.

OutlookForSend = RDCOMClient::COMCreate("Outlook.Application")
emailToSend = OutlookForSend$CreateItem(0)
emailToSend[["subject"]] = "Subject"
emailToSend[["HTMLBody"]] = bodyToSend
emailToSend[["To"]] = "Email"
emailToSend$Send()

However, I don't have outlook installed, in the server machine but still need to send emails.

I'm able to achieve the same using the package mailer in Python , what is the best way to achieve the same in R.

Thanks


Solution

  • Solved the problem, using mailR package and it works well.

    library(mailR)
    send.mail(from = "email@company.com",
              to = "email@company.com",
              subject = subjectToSend ,
              body = bodyToSend,
              html = TRUE,
              smtp = list(host.name = "smtp.company.com", port = 25), 
              send = TRUE)