sending mail from R (mailR)

旧街凉风 提交于 2019-12-04 12:04:09

If your gmail account is propertly setup (as mOnhawk suggested) then this form should work for the smtp list:

smtp = list(host.name = "smtp.gmail.com", port = 465,
                        ssl=TRUE, user.name = "mymailid@gmail.com",
                        passwd = "my password)

If you're using gmail account, you might need to allow acess to your account from less secure aplications, using this link https://www.google.com/settings/security/lesssecureapps

If you have as well a 2 step verification, you also need to deactivate that.

i am trying to send email using RDCOMClient and here is the code

library(RDCOMClient)

emails <- paste("emailid")
## init com api
OutApp <- COMCreate("Outlook.Application")
## create an email 
outMail = OutApp$CreateItem(0)
## configure  email parameter 
outMail[["To"]] = emails
outMail[["Cc"]] = "emailid"
outMail[["subject"]] = "Monthly Report for Compliance"
outMail[["body"]] = paste(" Please find the monthly report  completed for ",Sys.Date(),
                          ".\n\n instrument file is saved at:\n G:\\Data Science\\Monthly Check - Westlake\\Instruments and Issuers Compliance List
                          "
                          )

outMail[["attachments"]]$Add("G:\\Data Science\\Monthly Check - Westlake\\Instruments and Issuers Compliance List\\Instruments_tracked-.02202018.csv")    
outMail$Send()

I get the below error
<checkErrorInfo> 80020009 
No support for InterfaceSupportsErrorInfo
checkErrorInfo -2147352567

You can try the following example:

library(mail)

to <-  "albert.physik@gmail.com"
subject <- "mail of R"
msg <- paste("Testing!")
sendmail(to, subject , msg)

But only allows you to send 20 emails per day I hope you find it useful.

Luck!

Did you use empty string as the body?

I tried with my company email and also gmail. When I put

body = "", # quotation marks with nothing in between

it yields

Error in ls(envir = envir, all.names = private) : invalid 'envir' argument

While this works:

body = " ", # adding a space there

Don't know why at all... If you happened to have empty string, this might help.

Subject being empty string causes no problem:

subject = "", # quotation marks with nothing in between
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!