Re: [R] Does R have a command for sending emails?

From: Fernando Saldanha <fsaldan1_at_gmail.com>
Date: Tue 10 May 2005 - 23:27:38 EST

I want to thank all who have offered help on this topic. I was able to create a very simple email function that I have tested to work under Windows XP Professional and R 2.1.0. It uses Blat version 1.9.4.

send.mail<-function(addr, subject, source.file) {   mail.cmd <- paste("Blat", source.file, "-subject", dQuote(subject), "-to", addr, separator = " ", collapse = "")   

  system(mail.cmd, intern = FALSE)
}

The string source.file must have double backslashes instead of single backslashes. For example:

C:\\myfolder

One must first install Blat version 1.9.4, available at

http://www.blat.net/194/.

All that is needed is to unzip the downloaded file (Blat194.zip) and copy Blat.exe to a folder in the path. The other files inside Blat194.zip can be discarded.

FS

On 5/10/05, Frank E Harrell Jr <f.harrell@vanderbilt.edu> wrote:
> Fernando Saldanha wrote:
> > Is there a way to have an R program send an email?
> >
> > Something like this:
> >
> > address <- 'abc@d.com'
> > text <- 'This is the email body'
> > send.email(address, text)
> >
> > Thanks.
> >
> > FS
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> >
>
> Under Linux/Unix you can use code such as the following. This handles
> kmail and mail.
>
> if(mailer=='kmail') {
> tf <- tempfile()
> cat(cmd, file=tf)
> to <- paste('"', paste(to, collapse=','), '"', sep='')
> if(length(cc)) cc <- paste(' -c "', paste(cc,
> collapse=','),'"',sep='')
> if(length(bcc)) bcc <- paste(' -b "', paste(bcc,
> collapse=','),'"',sep='')
> } else {
> to <- paste(to, collapse=' ')
> if(length(cc)) cc <- paste(paste(' -c', cc), collapse='')
> if(length(bcc)) bcc <- paste(paste(' -b', bcc),collapse='')
> }
> cmd <- if(mailer=='kmail') paste('kmail -s "', title, '"', cc,
> bcc, ' --msg ', tf, ' ', to, sep='') else
> paste('echo -e "', cmd, '" | mail -s "',
> title, ' Reports"', cc, bcc, ' ', to, sep='')
> system(cmd)
>
> --
> Frank E Harrell Jr Professor and Chair School of Medicine
> Department of Biostatistics Vanderbilt University
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 10 23:31:38 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:40 EST