for emails I used this, that allows you to place emails templates as views...
quite useful 
http://wiki.web2py.com/Sending_Email_with_Plain_Text_HTML_Versions_plus_Attachments

On Mon, Jul 18, 2011 at 3:23 PM, Anthony <[email protected]> wrote:
> If you want to call the function from another function in the same
> controller, you could do something like this:
>
> def message():
>     # Code to create variables needed for output.
>     return dict(var1=...,var2=...,etc.)
>
> def mail_sender():
>     # Call the message() function and render its output using the
> message.email view.
>     email_content=response.render('default/message.email', message())
>     # Code to send the email message.
>     return # whatever this function should return
>
>
> If you need to call message() from somewhere else, you could move the part
> of the code that generates the variables for the output to a module or maybe
> a model. Or you could try using urllib2.urlopen() or the web2py fetch()
> function (see
> http://web2py.com/book/default/chapter/12#Fetching-an-external-URL). Just
> create a message.email view and use the .email extension when calling the
> URL.
>
> Anthony
>
> On Monday, July 18, 2011 5:47:31 AM UTC-4, Manuele wrote:
>>
>> hi *,
>>
>> I woulld like to reuse a controller function with a different view to
>> get an html message to send via email... how is it possible?
>>
>> Is there a way from python code to get the html text that is returned
>> when a browser call an url that correspond to my controller "dressed" by
>> my view with the same name of my controller and, for example, with
>> .email extension?
>>
>> many thanks
>>
>> Manuele
>

Reply via email to