David,

Yes, I understand that cat() won't do what I want, but that is the only way
I can illustrate what I am after. Note the phrasing in my question:
'...cat() like...'

Regarding assigning the paste  to a variable: it produces the same error.
I've already tried that.

Thanks for your suggestion!

Ben

On Tue, Aug 30, 2011 at 11:24 AM, David Winsemius <dwinsem...@comcast.net>wrote:

>
> On Aug 30, 2011, at 1:09 PM, Ben qant wrote:
>
>  Hello,
>>
>> (Sorry if this is a dup post...)
>>
>> I need to clarify, Henrique's suggestion worked great for getting the text
>> that I needed via cat(), but I haven't sorted out how to get cat() like
>> output into a variable so I can pass it into the message body variable I
>> am
>> using.
>>
>
> cat() is not the right function to get text assgned to an object. It's
> entire purpose is to have a side-effect and _not_ return anything into R's
> workspace. Why are you not assigning the result of that paste operation to
> the variable?
>
>
>
>
>> Here is what I mean:
>> x
>> [1] "a" "b" "c" "d"
>> paste(x,collapse='\n')
>> [1] "a\nb\nc\nd"
>> y = paste(x,collapse='\n')
>> cat(y)
>> a
>> b
>> c
>> d
>>
>> This is the problem with 'y' has the msg body:
>>
>> paste("msg = MIMEText('",y,"')",sep="")
>> [1] "msg = MIMEText('a\nb\nc\nd')"
>>
>> This is what I am after (I think!):
>>
>> paste("msg = MIMEText('",y,"')",sep="")
>> [1] "msg = MIMEText('a
>> b
>> c
>> d')"
>>
>>
>> Here is how I am actually using it (with sensitive items generalized):
>>
>> require(rJython)
>> rJython <- rJython()
>> rJython$exec( "import smtplib" )
>> rJython$exec("from email.MIMEText import MIMEText")
>> rJython$exec("import email.utils")
>>
>> mail<-c(
>> #Email settings
>> "fromaddr = 'ccqu...@gmail.com'",
>> "toaddrs  = 'userna...@somethinghere.com'"
>> - Show quoted text -
>> jython.exec(rJython,mail)  # and here is the error I get.
>>
>> Error in ls(envir = envir, all.names = private) :
>>  invalid 'envir' argument
>>
>>
>> Just in case someone asks, I can do this:
>>
>> y = "a test"
>>
>> ...and the above email sends fine with 'a test' as the msg body.
>>
>> Any ideas?
>>
>> PS - I received lots of suggestions. Thank you very much for your
>> effort/input.
>>
>> Ben
>>
>>
>> On Mon, Aug 29, 2011 at 6:01 PM, Henrique Dallazuanna <www...@gmail.com
>> >wrote:
>>
>>  Try:
>>>
>>> paste(c("a", "b", "c"), collapse = "\n")
>>>
>>> On Mon, Aug 29, 2011 at 8:56 PM, Ben qant <ccqu...@gmail.com> wrote:
>>>
>>>  Hello,
>>>>
>>>> Does anyone know how to convert this:
>>>>
>>>>> msg
>>>>>
>>>> [1] "a"
>>>> [2] "b"
>>>> [3] "c"
>>>>
>>>>
>>>> To:
>>>>
>>>>  msg
>>>>>
>>>> "a
>>>> b
>>>> c"
>>>>
>>>> In other words, I need to convert a character vector to a single string
>>>> with
>>>> carriage returns for each row.
>>>>
>>>> Functionally, I'm attempting to send an email of a character vector in a
>>>> way
>>>> that is readable in the email body. I can only input one string as the
>>>> message body parameter. I'm using rJython to send the email because I
>>>> need
>>>> authentication.
>>>>
>>>> Thanks!
>>>>
>>>>      [[alternative HTML version deleted]]
>>>>
>>>> ______________________________**________________
>>>> R-help@r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/**posting-guide.html<http://www.R-project.org/posting-guide.html>
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>>
>>>
>>>
>>> --
>>> Henrique Dallazuanna
>>> Curitiba-Paraná-Brasil
>>> 25° 25' 40" S 49° 16' 22" O
>>>
>>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> David Winsemius, MD
> West Hartford, CT
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to