[R] sendmail -- issue with mime_part
Dennis Fisher
fisher at plessthan.com
Thu Aug 15 18:29:27 CEST 2013
R 3.0.1
OS X 10.8.4
Colleagues,
I am using sendmailR to send myself notifications when a lengthy R process completes. Sample code is:
require("sendmailR")
NOTIFY <- "Notification"
FROM <- "<fisher at plessthan.com>"
TO <- FROM
CONTROL <- list(smtpServer="ASPMX.L.GOOGLE.COM")
HEADERS <- list(From=FROM)
# TEXT <- c("xxx", "yyy", "zzz")
TEXT <- data.frame(as.matrix(c("xxx", "yyy", "zzz"), ncol=1))
names(TEXT) <- "HEADERNAME"
BODY <- list(NOTIFY, mime_part(TEXT, name="SOMENAME"))
sendmail(from=FROM, to=TO, subject="TEST1", msg=BODY, control=CONTROL, headers=HEADERS)
The process is successful and TEXT appears in an attachment named SOMENAME.txt. So far, so good. However, the content of SOMENAME.txt is:
"HEADERNAME"
"1" "xxx"
"2" "yyy"
"3" "zzz"
I would like to get rid of the row numbers ("1", "2", "3"). I tried several variants of the assignment to TEXT. I discovered (please correct me if I am wrong) that TEXT needs to be a dataframe (and as.matrix. If it is not a dataframe, TEXT appears in-line within the email rather than as an attachment.
Also, ".txt" is appended to SOMENAME. If, for example, I wanted the file to be named SOMENAME.csv, the command -- name="SOMENAME.csv" would yield "SOMENAME.csv.txt". Is there some means to prevent addition of the .txt extension?
Any help would be appreciated.
Dennis
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
More information about the R-help
mailing list