Any chance a utility like this could be incorporated in base and used by bug.report. That would make the same utility available to everyone, rather than us all inventing the same thing over again.

Paul Gilbert

David James wrote:
David Khabie-Zeitoune wrote:

Hi

Does anyone know of any R routines to send emails from R, under Windows?
I thought about writing such a facility using the R(D)COM package to
drive e.g. MS Outlook, but I don't want to reinvent the wheel. I have
found a function Sys.mail in the library syskern, but this only works
under Unix by shelling out a mail command.


Thanks,

David

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


The R function sendEmail() below uses the RDCOMClient package
to control Outlook or Echange -- more precisely, it interfaces to
Microsoft's Collaboration Data Objects (CDO). (Please note that I don't use Windows for email, so I couldn't test the function.)



sendEmail(ema = "[EMAIL PROTECTED]",

name = "R-help mailing list", subject = "How to send Email from R using the RDCOMClient" msgBody = "here is the body of the message")

The package RDCOMClient is available at http://www.omegahat.org/RDCOMClient.

"sendEmail" <-
function(ema, name, subject, msgBody, deliverNow = TRUE)
{
   require(RDCOMClient)

ema <- paste("SMPT:", ema, sep="") ## prepend protocol to address

## create an e-mail session session <- COMCreate("Mapi.Session") session$Logon()

   ## add a message to the outbox collection of messages
   outbox <- session[["Outbox"]]
   msg <- outbox[["Messages"]]$Add(subject, msgBody)

## add recipient's name (TODO: addMultiple() or loop, if many recipients)
msg[["Recipients"]]$Add(name, ema) msg$Send()
if(deliverNow)
msg$DeliverNow()


   session$Logoff()   ## wrap up
}


______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

Reply via email to